Assume that you have a FILLED or OPENED order and you want to update the stop loss on every Eur/Usd 10 min bar:
@Override
public void onBar(Instrument instrument, Period period, IBar askBar, IBar bidBar) throws JFException {
if(instrument != Instrument.EURUSD || period != Period.TEN_MINS){
return;
}
//We can change SL only for FILLED and OPENED orders
if(order.getState() == IOrder.State.FILLED || order.getState() == IOrder.State.OPENED){
order.setStopLossPrice(bidBar.getLow());
}
}
See more:
https://www.dukascopy.com/wiki/#Set_Stop_Loss_price