Hello,
I think that I found 2 bugs in the latest version of JForex (Historical tester).
Test code:
public void onBar(Instrument instrument, Period period, IBar askbar,
IBar bidbar) throws JFException {
IBar prevBarAsk1 = history.getBar(instrument, period,
OfferSide.ASK, 2);
}
It throws exception:
Strategy tester: com.dukascopy.api.JFException: Could not load bar for instrument [EUR/USD], period [Hourly], side [Ask], start time [2011.03.01 08:00:00 000], current bar start time [2011.03.01 10:00:00 000]
The other problem is indicator values with Filter.ALL_FLATS
private final Filter indFilter = Filter.ALL_FLATS;
public static String arrayToString(double [][] arr){
String str = "";
for (int r=0; r<arr.length; r++) {
for (int c=0; c<arr[r].length; c++) {
str += " " + (new DecimalFormat("0.000000")).format(arr[r][c]);
}
str += "; ";
}
return str;
}
void printMsg(String text)
{
console.getOut().println(text);
}
public void onBar(Instrument instrument, Period period, IBar askbar,
IBar bidbar) throws JFException {
double macdNoFlat[][] = indicators.macd(instrument,period,OfferSide.BID,AppliedPrice.CLOSE,12,26,9,indFilter,0,askbar.getTime(),4);
printMsg(arrayToString(macdNoFlat));
}
I'm testing this code on EUR/USD, Last year. Values of macd in array are not equal to indicator on chart and values can change at next bar:
2012-03-31 15:08:43 0.000708 0.000635 0.000696 0.000649; 0.000843 0.000802 0.000780 0.000754; -0.000135 -0.000167 -0.000085 -0.000106;
2012-03-31 15:08:43 0.000790 0.000708 0.000635 0.000703; 0.000877 0.000843 0.000802 0.000782; -0.000087 -0.000135 -0.000167 -0.000079;
2012-03-31 15:06:28 0.000852 0.000790 0.000708 0.000626; 0.000899 0.000877 0.000843 0.000800; -0.000047 -0.000087 -0.000135 -0.000174;
2012-03-31 15:06:27 0.000855 0.000852 0.000790 0.000708; 0.000911 0.000899 0.000877 0.000843; -0.000055 -0.000047 -0.000087 -0.000135;
2012-03-31 15:06:27 0.000971 0.000855 0.000852 0.000788; 0.000924 0.000911 0.000899 0.000877; 0.000047 -0.000055 -0.000047 -0.000089;
2012-03-31 15:06:27 0.000886 0.000971 0.000855 0.000854; 0.000913 0.000924 0.000911 0.000899; -0.000027 0.000047 -0.000055 -0.000045;
2012-03-31 15:06:27 0.000804 0.000886 0.000971 0.000851; 0.000920 0.000913 0.000924 0.000910; -0.000116 -0.000027 0.000047 -0.000058;
2012-03-31 15:06:27 0.000806 0.000804 0.000886 0.000970; 0.000948 0.000920 0.000913 0.000924; -0.000143 -0.000116 -0.000027 0.000046;