I want to set a sell stop entry order, then add a stop based on the bid. I understand that I cannot do this until the order is opened, so I attempt to wait using a loop:
order = engine.submitOrder(theLabel, theInstrument, OrderCommand.SELLSTOP, tradeSize, entryPrice);
while(order.getState() == State.CREATED) {
Thread.sleep(1000);
System.out.print(".");
}
order.setStopLossPrice(entryPrice + offset, OfferSide.BID);
The problem is that the loop never ends (for several minutes at least). I thought the change of state from CREATED to OPENED should be quick? The trade size is small, no problems with the parameters that I can see. Values are rounded to nearest 0.00001 pips using Math.round.
What is wrong?