Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

tick.getTotalBidVolume() not working in Historical Tester; Help please.
 Post subject: tick.getTotalBidVolume() not working in Historical Tester; Help please. Post rating: 0   New post Posted: Fri 01 Jun, 2018, 17:37 

User rating: 4
Joined: Wed 23 May, 2018, 20:08
Posts: 44
Location: FinlandFinland
 public void onTick(Instrument instrument, ITick tick) throws JFException {
        if (instrument != this.instrument) {
            return;
        }
        double[] asks = tick.getAsks();
        double[] bids = tick.getBids();
        double[] askVolumes = tick.getAskVolumes();
        double[] bidVolumes = tick.getBidVolumes();
        double totalAskVolume = tick.getTotalAskVolume();
        double totalBidVolume = tick.getTotalBidVolume();
   
       
        for (int i =9; i < bids.length; i++) {
            console.getOut().println("Ask: " + asks[i] + " Bid: " + bids[i] + " Ask Volumes: " + askVolumes[i] +
                    " Bid volumes: " + bidVolumes[i] + " Total Ask Volume: " + totalAskVolume + " Total Bid Volume: " + totalBidVolume);


Can you please show me how to tick.getTotalBidVolume() in Historical Tester, please?


 
 Post subject: Re: tick.getTotalBidVolume() not working in Historical Tester; Help please. Post rating: 0   New post Posted: Mon 04 Jun, 2018, 17:00 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Historical Tester works in a different way. ITick stores only one best market BID/ASK offer. So, in back testing tick.getBids.length/tick.getAsks.length always will be 1.
And, accordingly, tick.getAskVolume/tick.getBidVolume = tick.getTotalAskVolume/tick.getTotalBidVolume.

In your example program will never go into the for loop, because ITick itself contains only one element, but you are trying to get 10th element.
Initialize i variable with 0, not with 9. I generally recommend always initialize i with 0, and if you need access to the last available market offer in ITick - use if condition.
And print volume logic also can be taken out from for-loop.

You can try this example:

public void onTick(Instrument instrument, ITick tick) throws JFException {
        if (instrument != this.instrument) {
            return;
        }
       
        double[] asks = tick.getAsks();
        double[] bids = tick.getBids();
        double[] askVolumes = tick.getAskVolumes();
        double[] bidVolumes = tick.getBidVolumes();
        double totalAskVolume = tick.getTotalAskVolume();
        double totalBidVolume = tick.getTotalBidVolume();

        console.getOut().println("Total Ask Volume: " + totalAskVolume + " Total Bid Volume: " + totalBidVolume);
        console.getOut().println("Total bid proposal count: " + bids.length + " Total ask proposal count: " + asks.length);
       
        for (int i = 0; i < bids.length; i++) {
            if (i == bids.length - 1) {
                console.getOut().println("Last element in array: " + " Ask: " + asks[i] + " Bid: " + bids[i] + " Ask Volumes: " + askVolumes[i] +
                        " Bid volumes: " + bidVolumes[i]);
            }
        }
    }


But, as I said, in HT you will always receive tick with only one offer in both OfferSides.


 
 Post subject: Re: tick.getTotalBidVolume() not working in Historical Tester; Help please. Post rating: 0   New post Posted: Mon 04 Jun, 2018, 17:20 

User rating: 4
Joined: Wed 23 May, 2018, 20:08
Posts: 44
Location: FinlandFinland
Hello,

Thank you for insight! I learned alot!


 

Jump to:  

cron
  © 1998-2025 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com