OCO does not exist on some platforms, and the workaround breaks
One-cancels-other orders are standard on many platforms. On MetaTrader 4 and 5, there is no native OCO for pending orders. Traders build it with scripts or EAs.
The script watches one order. When it fills, the script cancels the other. In a calm market, it works. In a fast market, a gap opens in the logic. Both orders can fill before the script reacts, especially when the platform is under load.
The same risk exists if the platform or the VPS disconnects at the wrong moment. The script stops running, and the unwanted order stays active.
A server-side OCO, offered by some brokers or platforms, avoids the problem because the matching happens at the broker.
When a strategy relies on OCO-style behaviour, testing in live conditions with small size is worthwhile. Demo may not show the gap.
Is the OCO logic in use handled on the server or on the client, and has anyone tested what happens during a disconnect?
OCO does not exist on some platforms, and the workaround breaks
-
Amanhasnoname
- Posts: 1506
- Joined: Fri Oct 30, 2026 9:45 am
Re: OCO does not exist on some platforms, and the workaround breaks
I used a client side script for this on MT4 for a while, bracketing the range before the London open, and it failed me in exactly the way you describe. On a fast open both orders filled within a second of each other, the script cancelled nothing because the first fill hadn't registered yet, and I was suddenly holding a buy and a sell on the same pair.
Then there was a VPS restart one night that I didn't notice. The script stopped, one order filled the next morning, and the opposite pending order was still sitting there when I logged in. Nothing terrible happened, but it was a lucky escape.
After that I stopped relying on it for anything important. I now place just one side when the bias is clear, or wait for the break and enter manually. If I ever go back to bracket orders it will be with a broker that does the cancelling on their server.
Then there was a VPS restart one night that I didn't notice. The script stopped, one order filled the next morning, and the opposite pending order was still sitting there when I logged in. Nothing terrible happened, but it was a lucky escape.
After that I stopped relying on it for anything important. I now place just one side when the bias is clear, or wait for the break and enter manually. If I ever go back to bracket orders it will be with a broker that does the cancelling on their server.
-
Shadow Trader
- Posts: 5438
- Joined: Wed Sep 09, 2026 5:19 pm
Re: OCO does not exist on some platforms, and the workaround breaks
The classic news setup: two pending orders, one above and one below. When the number hits, one side triggers and the other gets cancelled. That's the theory. Reality offers an alternative.
On a whipsaw, price spikes up, triggers the buy, reverses sharply through the sell level, and triggers that too. Now there are two positions, one long and one short, both opened at bad prices, with stops placed against the opposite spikes. The loss exceeds anything planned.
Even with OCO (one cancels other) orders, the cancellation takes time. At times of overloaded servers, both fills can arrive before the cancel is processed.
Wide spreads make it worse. The trigger distance has to exceed the spread expansion, otherwise orders fire from the spread change alone, before any real move occurs.
Alternatives exist. A single directional order after the first reaction. A wait-and-see approach that uses the first 30 seconds as information. A bracket with much wider distances and reduced size.
Brokers vary in OCO support, and many retail platforms don't offer true OCO at all.
After a straddle caught both sides, what changed in the approach?
On a whipsaw, price spikes up, triggers the buy, reverses sharply through the sell level, and triggers that too. Now there are two positions, one long and one short, both opened at bad prices, with stops placed against the opposite spikes. The loss exceeds anything planned.
Even with OCO (one cancels other) orders, the cancellation takes time. At times of overloaded servers, both fills can arrive before the cancel is processed.
Wide spreads make it worse. The trigger distance has to exceed the spread expansion, otherwise orders fire from the spread change alone, before any real move occurs.
Alternatives exist. A single directional order after the first reaction. A wait-and-see approach that uses the first 30 seconds as information. A bracket with much wider distances and reduced size.
Brokers vary in OCO support, and many retail platforms don't offer true OCO at all.
After a straddle caught both sides, what changed in the approach?