Obviously you can program this so that you create a bracket order with a stop-loss but no take-profit: as soon as the entry order fills, create the two take-profit orders, and then monitor the stop-loss so that if it fills, you can cancel the take-profits. Easy enough, provided you use a stop order for your stop-loss rather than a stop-limit, which then gives you potential complications with partial fills. And of course ?your program has to keep running to ensure that the take-profits are cancelled if need be.
?
A possible alternative that I haven't tried but seems like it should work is to create your initial bracket order with stop-loss and a single take-profit, and then when the entry order fills, halve the size of the OCA group containing the stop-loss and take-profit, and then create another OCA group containing another half-size stop-loss and the other take-profit. Once that's done you can walk away, as it were. The only question in my mind is whether you can actually change the size of an OCA group that was once attached to a parent order, but I can't see why it wouldn't be allowed. I'll try this when I've got a few spare minutes.
From:[email protected] <[email protected]> On Behalf Of Levente Sent: 28 April 2021 22:48 To:[email protected] Subject: [TWS API] Can a bracket order have two take profit orders to exit a position at two different profit levels?
?
I would like to know if there is a mechanism that would allow me to place a position opening order for N contracts, together with two take profit orders, each of size N/2 but at different price levels. If I create a bracket order with these 3 orders, when the position opening order fills the two take profit orders will be activated, but they will belong to the same OCA group, so that when the first one fills, the other will get cancelled automatically, which is not what I want.