Hello Support,
due to this bug
https://www.dukascopy.com/swiss/english/forex/jforex/forum/viewtopic.php?f=17&t=23835 I have been forced to do my setup of indicators in the onTick of the strategy instead of the onStart(). In doing this work around I have noticed that getBar function will return the most recent bar as null if the following strategy is run in the main.java from my IDE (and not from the JForex frontend). If this if statement is moved to the onBar then a null bar will not be returned. And if the .getBar shift is set to 1 instead of 0, null will also not be returned.
Any chance this bug could be fixed? And also when will the API with the above mentioned fixed bug be released?
Thanks for your help,
jForexUser
import java.util.*;
import com.dukascopy.api.*;
public class Strategy implements IStrategy {
private IEngine engine;
private IConsole console;
private IHistory history;
private IContext context;
private IIndicators indicators;
private IUserInterface userInterface;
boolean runJustOnce = true;
public void onStart(IContext context) throws JFException {
this.engine = context.getEngine();
this.console = context.getConsole();
this.history = context.getHistory();
this.context = context;
this.indicators = context.getIndicators();
this.userInterface = context.getUserInterface();
}
public void onAccount(IAccount account) throws JFException {
}
public void onMessage(IMessage message) throws JFException {
}
public void onStop() throws JFException {
}
public void onTick(Instrument instrument, ITick tick) throws JFException {
if (runJustOnce) {
IBar current_TEN_SECS = context.getHistory().getBar(instrument, Period.TEN_SECS, OfferSide.BID, 0);
console.getOut().println("close: " + current_TEN_SECS.getClose());
runJustOnce = false;
}
}
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
}
}