Advertisement IC Markets

Emulating OCO orders in an EA and the double-fill trap

Compare ECN/Raw spread brokers, analyze execution speeds, report slippage, and evaluate commission structures for high-frequency traders.
Post Reply
Amanhasnoname
Posts: 1506
Joined: Fri Oct 30, 2026 9:45 am

Emulating OCO orders in an EA and the double-fill trap

Post by Amanhasnoname »

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?
Recommended broker for automated trading & scalping IC Markets
Post Reply