I have a bug in my code where a position is getting closed and I cannot work out why, I’ve commented out all the places where the position is closed explicitly by the code and it makes no difference, so I assume it has something to do with a pending order.
Is this the way to clear pending stop and target orders?
set stop price 0
set target price 0
Surely above code IS the reason your trades are getting closed?
Those instructions disable SL and TP, as there’s no need to disable pending orders because they expire every candle and you simply stop placing them if you don’t want them.
I found the cause of my bug it was not related to the stop and target orders.