Canceling the Untriggered Stop After a Take-Profit or Stop-Loss Fill
Summary
The forum exchange addresses a bracket-order problem: when a take-profit stop and a protective stop are both active, a rapidly moving one-minute bar may cross both prices. The suggested approach is to place both as local stop orders and let the strategy engine evaluate them at tick level, where one should trigger first. Once the position-closing trade is received, the strategy should cancel the other still-active stop order.
To do that, the reply recommends keeping a local record of active orders and using the order identifier to cancel the remaining order from the trade callback. The discussion gives a practical event-driven order-management pattern, but it is not a full implementation and does not discuss race conditions, partial fills, cancellation acknowledgments, or behavior when both orders have already triggered. Those details matter when adapting the idea to a particular engine and order model. The exchange supplies no backtest or live-trading evidence; its value is as a concise implementation concept for coordinating paired exit orders.
Key ideas
- The scenario involves active take-profit and stop-loss orders both being crossed during a fast bar.
- The reply recommends local stop orders that the engine checks at tick level.
- After a closing fill arrives, cancel the other active stop using its order identifier.
- Reliable handling also depends on tracking order state and accounting for partial fills or simultaneous triggers.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.