Hi,
not sure if this is a bug or not, anyway, it seems that under certain circunstances, the onbar event appears to stop being called, particullarly when there are order commands involved. Consider the following simple strategy, running on the tester on tick data:
package Strategies;
import java.text.SimpleDateFormat;
import java.util.Calendar;
import com.dukascopy.api.*;
public class BUG implements IStrategy {
long barNumber = 0;
IEngine engine;
IConsole console;
private static final String DATE_FORMAT_NOW = "yyyyMMdd_HHmmssSSS";
long counter = 0;
public void onStart(IContext context) throws JFException {
engine = context.getEngine();
console = context.getConsole();
}
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
if (period == Period.FIVE_MINS) {
console.getOut().println(++barNumber);
IOrder longOrder = engine.submitOrder("LONG" + getCurrentTime() + counter++, instrument, IEngine.OrderCommand.BUY, 0.01);
waitUntilOrderFilled(longOrder);
IOrder shortOrder = engine.submitOrder("SHORT" + getCurrentTime() + counter++, instrument, IEngine.OrderCommand.SELL, 0.01);
waitUntilOrderFilled(shortOrder);
}
//else
// console.getOut().println(period);
}
public void onTick(Instrument instrument, ITick tick) throws JFException {}
public void onAccount(IAccount account) throws JFException {}
public void onStop() throws JFException {}
public void onMessage(IMessage message) throws JFException {}
private String getCurrentTime() {
Calendar cal = Calendar.getInstance();
SimpleDateFormat sdf = new SimpleDateFormat(DATE_FORMAT_NOW);
return sdf.format(cal.getTime());
}
private void waitUntilOrderFilled(IOrder order) {
while (!order.getState().equals(IOrder.State.FILLED) && !order.getState().equals(IOrder.State.CANCELED))
order.waitForUpdate(1000);
}
}
The print statements are being used for debug, but after certain number of bars the strategy stops printing and the test run cancel button will not respond.
I have deleted my cache and tried again but the results remain the same.
Thanks for your attention,
Regards,