OCO (One Cancels Other) Orders for News Trading
The Logic of the Simultaneous Stop: What is OCO?
An OCO (One Cancels Other) order is a pair of pending orders linked by a script or EA. If one order is triggered, the other is automatically deleted. This is a critical tool for traders who want to catch explosive breakouts without knowing which direction the market will move.
In a standard news-straddle strategy, you place a 'Buy Stop' above the current price and a 'Sell Stop' below it. Without OCO logic, you risk having the market trigger BOTH orders (double-whipsaw), which can lead to massive losses. OCO ensures that you only commit to one direction at a time.
MT4 Limitation: Why you need an EA for OCO
MetaTrader 4 does not natively support OCO orders in its basic interface. If you place two pending orders manually, they are completely independent. To achieve OCO functionality, you must use a Background Expert Advisor or script that constantly monitors your account.
Once the EA detects that the OrderType() of a pending order has changed to an 'Active' market position (OP_BUY or OP_SELL), it immediately sends a delete command for the remaining pending order. This must happen in milliseconds to be effective during high-volatility events like NFP or interest rate announcements.
{ OCO Order Checklist }
Sequence: Place 2 pending orders / Link via Magic Number
Threshold: Minimum distance of 10 pips to avoid double-triggers
Constraint: Use an EA that monitors OnTick() for state changes
Market State: Only use during high-impact news (e.g., NFP)
Verified: Ensure the EA logs 'Pending Order Deleted' instantly
Risk: Use a hard Stop-Loss in both pending orders for safety
Coding OCO Logic: The OrderDelete Function
Implementing OCO in MQL4 involves a loop that iterates through all pending orders with a specific Magic Number. The logic is: if (activeTradesCount > 0) { DeleteAllPendingOrders(MagicNumber); }.
It is important to use a Safety Offset. During extreme news spikes, both pending orders might be hit by the same high-velocity price candle before the EA has time to process the first deletion. Setting the OCO orders far enough apart (e.g., 10-15 pips) is the best way to prevent 'Double-trigger' failures.
Strategy: Automating the News Straddle
The OCO mechanic is the engine of the Straddle Strategy. Five minutes before a major news event, the EA places OCO orders 20 pips above/below the market. If the news is positive, the Buy Stop hits, and the Sell Stop is deleted. If the news is a disappointment, the Sell Stop hits, and the Buy Stop is deleted. This 'Catch the Wave' approach is used by many HFT and low-latency algorithmic firms.