Hi,
in the OnBar or the OnTick method, the following code allows editing the stop loss of an open position:
Quote:
if (engine.getOrders().size() > 0) {
for (IOrder orderInMarket : engine.getOrders()) {
if (orderInMarket.isLong() && (order.getState().equals(IOrder.State.FILLED))) {
(...)
order.setStopLossPrice(value, OfferSide.ASK, 10);
}
}
if (!orderInMarket.isLong() && (order.getState().equals(IOrder.State.FILLED))) {
(...)
order.setStopLossPrice(newvas, OfferSide.BID, 10);
}
}
}
}
The code
only edits
one position though. As my strategy opens up up to 10 positions, i would like all the short positions to have one common stop loss and the long positions to have a common one as well. Is there any way to edit this code to make that happen? Otherwise i would only be able to have one long and one short position at a time.
Thanks in advance.
