Hi everyone, noticed an interesting thing. If I have 2 bracket orders (with take profit and stop loss) on the same contract and one stop loss triggered then it cancel another stop loss, but closes position with quantity specified in triggered bracket order. So I end up with open position without any stop loss or take profit. I figured out that I can check if there are open orders and add their quantity to a quantity of a new brackets stop loss/take profit order. But maybe there is some other way to figure this out. Maybe there is some way to made TWS close position with all quantity specified in all open orders.
That looks like you are configuring the orders wrong. The two stops losses in each of the bracket orders should be independent, you seem to be associating them together, eg with the same group name.
They are independent, have different order id and have their own parent order. And when one stop loss triggers another being canceled (take profit order too)
but also I noticed that it happens only sometimes, not in all cases. Maybe because I'm using paper trading account and tws has some lags
Your stop losses seem to be interlinked. I think if you’ll do something about that, you might have a solution.