To Dukascopy Support,
I have an automated strategy based on momentum. Here is the main code.
public void onTick(Instrument instrument, ITick tick) throws JFException {
if (instrument != this.instrument) {
return;
}
if (!isActive(order)) {
order = null;
} else if(order.equals(IOrder.State.CREATED)) {
return;
}
double[] mom1 = indicators.mom(instrument, selectedPeriod1, offerSide, appliedPrice, momPeriod, filter, 1, tick.getTime(), 0);
if (order.isLong() && (mom1[0] < -0.0005)) {
closeOrder(order);
}
if (!order.isLong() && (mom1[0] > 0.0005)) {
closeOrder(order);
}
if (mom1[0] > 0.0005) {
if (order == null || !order.isLong()) {
closeOrder(order);
order = submitOrder(OrderCommand.BUY, instrument);
}
}
if (mom1[0] < -0.0005) {
if (order == null || order.isLong()) {
closeOrder(order);
order = submitOrder(OrderCommand.SELL, instrument);
}
}
}
When I test this strategy on the historical tester, it shows the following error
Quote:
Exception java.lang.NullPointerException @ jforex.Final_Test_6.onTick(Final_Test_6.java:102)
I understand that there is an error on line 102. This is code on line 102.
if (order.isLong() && (mom1[0] < -0.0005)) {
closeOrder(order);
}
But I don't understand what is wrong. Kindly tell me what is the mistake.
Regards,
Terry.