OCO Bracket Orders: How Stop Loss and Take Profit Copy
Automatic detection and replication of linked TP/SL brackets with native broker-level OCO support.
8 min read
When a leader places a bracket order — a take profit (TP) and stop loss (SL) that are linked so filling one cancels the other — MimikTrader detects both legs, pairs them together, and replicates them on follower accounts as a native OCO (One Cancels Other) order. This means the broker handles the cancellation logic, not MimikTrader, providing the same level of reliability as if you placed the bracket manually.
How Bracket Orders Are Detected
MimikTrader monitors the leader account's WebSocket feed for working order events. When the leader places a stop loss or take profit order, MimikTrader sees it as a new working order with specific characteristics:
- Take profit: A Limit order on the opposite side of the leader's open position. For a long position, this would be a Sell Limit above the current price.
- Stop loss: A Stop order on the opposite side of the leader's open position. For a long position, this would be a Sell Stop below the current price.
The detection happens through the WebSocket order event stream. When MimikTrader sees a TP or SL order arrive, it does not immediately place it on followers. Instead, it enters a pairing window to check if both legs are present.
The 1-Second Bracket Pairing Window
When MimikTrader detects the first leg of a potential bracket (either a TP or SL), it starts a 1-second pairing window. During this window, it waits for the other leg to arrive. Most trading platforms and order entry tools send both legs within milliseconds of each other, so 1 second provides ample time for both to arrive.
Three outcomes are possible:
- Both legs arrive within 1 second: MimikTrader pairs them and sends a native OCO bracket to each follower. This is the ideal case and produces a single atomic bracket at the broker level.
- Only one leg arrives: After the 1-second window expires, MimikTrader places the single leg as an individual order (a standalone Limit for TP, or a standalone Stop for SL) on each follower. No OCO linkage is created.
- Neither leg is configured to copy: If the copy group has both Copy Take Profit and Copy Stop Loss disabled, the bracket orders are ignored entirely.
Native Tradovate OCO via startOrderStrategy
When both legs are paired, MimikTrader uses Tradovate's native OCO mechanism through the startOrderStrategy API endpoint. This creates a server-side order strategy where Tradovate itself manages the linkage between the two orders:
- The TP leg is placed as a Limit order at the take profit price.
- The SL leg is placed as a Stop order at the stop loss price.
- Both orders are linked with an OCO strategy type. When one fills, Tradovate automatically cancels the other.
- The orders are tagged as automated and include the group tag for identification in your Tradovate account.
This approach is superior to managing the cancellation in MimikTrader's code because the OCO linkage is enforced at the exchange level. Even if MimikTrader loses connectivity momentarily, the bracket remains intact on Tradovate's servers.
Copy Group Configuration
Each copy group has two toggles that control bracket order behavior:
- Copy Take Profit: When enabled, TP limit orders from the leader are replicated on followers.
- Copy Stop Loss: When enabled, SL stop orders from the leader are replicated on followers.
When both are enabled and both legs arrive within the pairing window, MimikTrader sends a native OCO bracket. When only one is enabled, only that leg is sent as an individual order — no OCO linkage is created because there is only one order.
What Happens If Only One Leg Copies
There are scenarios where only one leg of the bracket can be placed on a follower:
- The copy group has Copy Take Profit enabled but Copy Stop Loss disabled (or vice versa). In this case, only the enabled leg is placed as an individual order.
- One leg arrives but the other never appears within the pairing window. The single leg is placed as a standalone order.
- The native OCO placement fails at the broker (rare, but possible during high-load periods). MimikTrader falls back to placing each leg as an individual order.
Fallback to Individual Orders
When the OCO placement fails or is not possible, MimikTrader falls back to placing each leg as a separate, unlinked order. In this fallback mode:
- The TP is placed as a standalone Limit order.
- The SL is placed as a standalone Stop order.
- There is no automatic cancellation linkage — if the TP fills, the SL remains working (and vice versa). MimikTrader will handle the cleanup when the leader's corresponding order is canceled.
Order Modification Propagation
When the leader modifies a working bracket order — for example, moving the stop loss price up to lock in profits — MimikTrader detects the modification through the WebSocket feed and propagates it to follower accounts. The modification is applied to the corresponding working order on each follower.
This applies to both price changes (moving the TP or SL level) and quantity changes. However, if the follower's order was placed at a different quantity due to sizing rules, the quantity modification is adjusted proportionally rather than copying the leader's exact new quantity.
Position Validation
Before placing a bracket on a follower, MimikTrader validates that the leader actually has an open position in the relevant contract. If the leader is flat (position is zero), bracket orders are skipped. This prevents orphaned TP/SL orders from being placed on followers when the leader has already closed the trade.
Similarly, if a follower is flat in the contract but the leader has an open position with brackets, the bracket is not placed on that follower. Brackets only make sense when there is a position to protect.