Emulating OCO orders in an EA and the double-fill trap
Posted: Sat Oct 31, 2026 2:18 pm
One-cancels-other orders let a trader place a buy stop and a sell stop together, with the filled one cancelling its twin. Many retail platforms do not support true OCO, so EAs emulate it by watching for one to fill and then deleting the other.
The emulation has a gap. Between the fill and the deletion, both orders can trigger in a whipsaw. The delete request needs time, and during a spike price can reverse through the other level before the cancel lands.
The outcome is two opposing positions, each paying spread, each with its own stop. In a volatile market, both can lose.
Reducing the risk requires speed and checks. Use the smallest possible delay in the monitoring loop, handle fills within the tick event, and place the deletion request immediately. Verify afterward that only one position exists.
Alternatively, use a platform with native OCO support. Some trading platforms and APIs offer it directly.
The cleanest fix is avoiding straddle-style entries during the most volatile minutes.
Has an OCO emulation ever produced an accidental double position?
The emulation has a gap. Between the fill and the deletion, both orders can trigger in a whipsaw. The delete request needs time, and during a spike price can reverse through the other level before the cancel lands.
The outcome is two opposing positions, each paying spread, each with its own stop. In a volatile market, both can lose.
Reducing the risk requires speed and checks. Use the smallest possible delay in the monitoring loop, handle fills within the tick event, and place the deletion request immediately. Verify afterward that only one position exists.
Alternatively, use a platform with native OCO support. Some trading platforms and APIs offer it directly.
The cleanest fix is avoiding straddle-style entries during the most volatile minutes.
Has an OCO emulation ever produced an accidental double position?