Hi,
To submit a buy stop order please use the
OrderCommand.BUYSTOP in the
submitOrder method. If you want to submit order after certain bar is completed, please use the
onBar method with filters. Please consider the following code to submit the stop buy stop order:
private double stopLossPrice;
private double takeProfitPrice;
private double stopPrice = 1.3230;
private double lot = 0.01;
public void onBar(Instrument instrument, Period period, IBar askbar, IBar bidbar) throws JFException {
if (instrument.equals(Instrument.EURUSD) && (period.equals(Period.FIFTEEN_MINS) || period.equals(Period.ONE_HOUR) || period.equals(Period.FOUR_HOURS)
|| period.equals(Period.DAILY)) ) {
stopLossPrice = stopPrice - (5 * instrument.getPipValue());
takeProfitPrice = stopPrice + (20 * instrument.getPipValue());
engine.submitOrder("StopOrder1", instrument, OrderCommand.BUYSTOP, lot, stopPrice, 0, stopLossPrice, takeProfitPrice);
}
}
Please take a look at the following JForex Wiki page for details how to filter bars:
https://www.dukascopy.com/wiki/index.php ... Ticks/Bars. For details about submitting conditional order, please consider the following JForex Wiki:
https://www.dukascopy.com/wiki/index.php ... onal_Order