Hello everybody,
here I want to leave fragment of code related to submitOrder:
public void onStart(IContext context) throws JFException {
IEngine engine = context.getEngine();
IHistory history = context.getHistory();
Instrument instrument = Instrument.EURUSD;
context.setSubscribedInstruments(java.util.Collections.singleton(instrument), true);
ITick lastTick = history.getLastTick(instrument);
double price = lastTick.getAsk() + instrument.getPipValue() * 5;
double sl = lastTick.getAsk() - instrument.getPipValue() * 20;
double tp = lastTick.getAsk() + instrument.getPipValue() * 10;
long gtt = lastTick.getTime() + TimeUnit.SECONDS.toMillis(30); //withdraw after 30 secs
IOrder order = engine.submitOrder("BuyStopOrder", instrument, OrderCommand.BUYSTOP, 0.1, price, 20, sl, tp, gtt, "My comment");
}
For me it was a challenge to find sequence of arguments to pass into submit order related to stop loss, take profit.