Hi, I'm using an exit strategy in my code, as well as a stop order for protection. Thus, upon reaching exit conditions of a trade, my code looks like this:
...
Trade.cancelAllOrders(getSymbol());
tempid=Trade.sellMarket(getSymbol(),nqty);
debugPrintln(getSymbol()+" position close via SELL MARKET order with OID "+tempid);
...
Now I've tested this with paper trading and it worked great, used it for several trades in Live Trading via an IB account and it also worked great. This is why I was surprised to notice today that the aforementioned code DID NOT CANCEL MY STOP ORDER even though it closed my position with the sellMarket order!
So basically the first line of code was ignored/did not execute and then the 2nd and 3rd did!
Do you have any idea why this could happen? I've checked my settings and they seem fine, and just yesterday the code worked correctly on the same symbols with the same IB account and settings. Normally I'd suspect a disconnect from the broker but would it even be possible for that to happen and for a reconnect to occur BEFORE the immediate next line of code was executed? It seems highly unlikely.
I'd appreciate any ideas as to the cause of this behavior.
Thank you
...
Trade.cancelAllOrders(getSymbol());
tempid=Trade.sellMarket(getSymbol(),nqty);
debugPrintln(getSymbol()+" position close via SELL MARKET order with OID "+tempid);
...
Now I've tested this with paper trading and it worked great, used it for several trades in Live Trading via an IB account and it also worked great. This is why I was surprised to notice today that the aforementioned code DID NOT CANCEL MY STOP ORDER even though it closed my position with the sellMarket order!
So basically the first line of code was ignored/did not execute and then the 2nd and 3rd did!
Do you have any idea why this could happen? I've checked my settings and they seem fine, and just yesterday the code worked correctly on the same symbols with the same IB account and settings. Normally I'd suspect a disconnect from the broker but would it even be possible for that to happen and for a reconnect to occur BEFORE the immediate next line of code was executed? It seems highly unlikely.
I'd appreciate any ideas as to the cause of this behavior.
Thank you
Comment