there are certain code to setup SL price.
engine.submitOrder(getLabel(instrument), instrument, OrderCommand.BUY, amount,0, 5);
for (IOrder orderInMarket : engine.getOrders())
{
orderInMarket.setStopLossPrice(boll[2][boll_len]);}
}
at first i tried to use orderCommand.PLACE_OFFER or PLACE.BID,but just found that order not trigger even where it should be.so i changed the code using BUY and SELL instead ,with a for-loop following to setup SL Price once order traded.code just shown above .
the problem is i backtested this strategy and the warning below shown up:
Strategy tester: com.dukascopy.api.JFException: Order state immutable @ Dukascopy.strategies.indicators.SMAStrategy_1.onBar(SMAStrategy_1.java:109)
below is the code i wrote with PLACE_OFFER or BID
engine.submitOrder(getLabel(instrument), this.instrument, orderCmd, this.amount*n, 0, 5, boll[2][boll_len],takeProfitPrice,goodTillTime);