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.