Learn › Glossary › OCO (One-Cancels-Other)

OCO (One-Cancels-Other)

A pair of linked orders where the execution of one automatically cancels the other — most commonly a take-profit limit and a stop-loss protecting the same shares. Without OCO linkage, a filled stop could leave a live sell limit that later executes as an accidental short.

An OCO order links two orders so that only one of them can ever fill. OCO stands for one-cancels-other. The usual pairing protects shares already owned: a sell limit above the market to take a profit, and a sell stop below the market to cap a loss. If the limit fills, the stop is cancelled. If the stop fills, the limit is cancelled. The broker enforces the link, so neither exit depends on a program or a person remembering to clean up.

The link exists because two exits on the same shares can both be live at once. Each order is valid on its own, and the broker has no reason to question a resting sell limit just because a different sell order already closed the position. Without the cancel rule, a stop that sells the whole position leaves the profit target resting. If the price later rises to that level, the target executes against shares that are gone, and the account ends up short. The bracket order is the same idea with the entry order attached, so a bracket always contains an OCO pair.

The mechanics of the pair come first, then the way it fails when the link is missing, then how far apart the two legs have to sit on different kinds of funds. The measured behaviour of SPY, QQQ, IWM, TQQQ, TLT and UVXY comes from the engine run over 2021-01-04 to 2026-10-02. The strategy templates that depend on one leg of a pair, a profit target or a trailing exit, are summarised with their medians across 59 ETFs. The library does not backtest OCO as a separate order type, and the last sections say what that leaves open.

What an OCO pair does, leg by leg

Both legs are submitted together and both rest at the broker. A take-profit leg is a limit order. It fills only at its price or better, so it waits until the market trades up to it. A stop leg is a trigger. It sits idle until price falls to the stop level, and then it becomes a live order, usually a market order, which is why the fill price can differ from the stop level. The stop-loss order page describes that second behaviour in more detail.

The cancel rule fires on a fill. When one leg executes, the broker removes the sibling in the same step. The pair also reacts to partial fills in a particular way. If the limit leg fills half the shares, a correctly built pair reduces the stop leg to the shares still held. Brokers differ in how they handle that case, and that difference is one reason a trader checks a broker's order documentation before relying on any linked order.

Three situations come up repeatedly:

The third case matters for strategies that also use a clock. A weekly rule that sells on Thursday afternoon has to cancel both legs first, or sell through them. If it sends a plain market sell while a target and a stop are still resting, the position closes and two live sell orders remain. That is the same orphaned-order hazard as the filled stop, reached by a different route.

How an unlinked pair ends in an accidental short

The failure is easier to see with a small example than with a definition. Take a position of 100 shares with a sell limit at the target and a sell stop below the entry, placed as two separate orders. The market falls, the stop triggers, and all 100 shares are sold. The account now holds zero shares and one resting sell limit for 100 shares.

Nothing about that limit order is invalid. Brokers accept sell limits on accounts that hold no shares only if the account is allowed to short, and many accounts are set up that way by default or by margin approval. If the price later recovers to the target, the order fills and the account is short 100 shares at a price the strategy never intended to sell at. From that point the account has exposure that rises when the market falls, and the trader may not know it exists until the next statement.

The same thing can happen in the other direction with a buy-side exit on a short position. The mechanism is symmetrical, and the cancel link is the only part that prevents it.

Two properties make this failure hard to catch in a backtest. A simulation that treats a filled stop as the end of the trade never shows the resting limit, because the simulated order list is cleared when the position closes. The live account has no such clearing step. The second property is timing. The orphaned limit may sit for days before it fills, long after the trade that created it has been logged as finished.

DeployQuant's product reference describes the account-level side of this problem in its sleeve rules. Each strategy runs in its own sleeve, every order is tagged with the strategy that placed it, and a strategy that sells everything only sells its own positions. Those rules limit what one strategy's leftover order can touch. They sit beside the broker's linked orders and do not replace them.

Gaps and what the stop leg really fills at

A stop leg is a promise to start selling at a level, not a promise of a price. The size of the gap between one close and the next open sets how far a fill can land from the level. The table of buy-and-hold statistics for each fund gives the average overnight gap and the average intraday range.

SPY averaged a 0.44% overnight gap and a 1.15% intraday range. QQQ averaged 0.59% and 1.58%. IWM averaged 0.61% and 1.75%. TLT, the long-bond fund, averaged 0.54% and 0.94%. TQQQ averaged a 1.78% overnight gap and a 4.74% intraday range. UVXY averaged 2.53% and 7.03%.

Those are averages, and the averages describe an ordinary day. They show the scale. On SPY the average gap is well under half of one percent, so a stop placed a few percent below the entry is usually reached by trading within a session, and the fill lands close to the stop level. On TQQQ the average gap is already larger than the whole intraday range of SPY. A stop placed 5% below the entry can be crossed by the open alone, and the fill then happens at the open, below the stop.

An OCO pair does nothing about that. The stop leg still converts to a market order at the trigger, and the limit leg is cancelled when it fills. The linkage solves the problem of two live orders. It does not change what price the surviving order gets. A trader who widens the stop to avoid noise and a trader who tightens it to cap loss are both choosing a point on the same trade-off, and the gap statistics say how much slippage past the level to expect on each fund.

How far apart the two legs sit on different funds

The width of the pair has to fit the fund. A 7% target on SPY needs a move that the fund's average day of 0.74% up or 0.74% down takes many sessions to build. The same 7% target on TQQQ, whose average up day is 3.01% and average down day is 3.22%, can be reached in a few sessions. The first pair rests for days or weeks. The second one can complete before the end of the week.

The drawdown counts show the same scale. The engine counted every time a fund fell 10% from its 20-day high. SPY did it 11 times over the window, spending 23 days in that state. QQQ did it 21 times and spent 82 days there. IWM did it 26 times for 67 days. TLT did it 3 times for 5 days. TQQQ did it 56 times for 478 days. UVXY did it 81 times for 1,130 days.

A stop set 10% below an entry therefore means very different things across those funds. On TLT it would almost never have been reached by a normal pullback. On TQQQ it sits inside the range of a routine pullback, and a stop-loss leg at that distance would have been triggered often. The TQQQ page shows the full drawdown history, including the 81.68% fall from the 2021-11-19 peak to the 2022-12-28 trough. The SPY page shows a 24.51% fall over a similar stretch.

The profit leg has the same sensitivity. UVXY fell 99.94% over the window, from $10,000 to about $216 on a buy-and-hold basis, with a 72.83% annual loss rate. A take-profit limit on a long UVXY position would have filled many times on the spikes, with each rally followed by a decay. A take-profit on a long position in a fund that kept rising, such as SPY with its 26.18% in 2023 and 24.86% in 2024, would have capped gains that kept coming. The UVXY page and the IWM page show the other extremes, a decaying fund and a fund that gained 55.8% in total over the window.

Which library strategies lean on one leg of the pair

The 12 templates in the library are built from daily decisions, and several of them use a resting exit. None of them is an OCO strategy in the strict sense, since none places both a target and a stop at the same time. They show what each leg does when it works alone.

The weekly 7% target buys at the first open of the week, rests a +7% profit target, and exits Thursday afternoon if the trade is losing. It has a take-profit leg and a time exit. Across 59 ETFs its median CAGR was 6.61%, its median maximum drawdown was 26.26%, and it made a median of 106 round trips. It beat buy-and-hold on 34 of the 59 funds. The count of trips is the reason the target leg matters. A rule that places a new target order for every trade needs each one created and cleaned up without fail.

The dip buyer waits for a 10% drawdown from the 20-day high, buys it, and takes profit at +8%. That is a pure take-profit leg with no stop. Its median CAGR was 1.33% and its median drawdown 26.19%, with a median of 2 round trips, so a resting target exists for long stretches with almost nothing happening. It beat buy-and-hold on 22 of 59 funds. Without a stop leg, a position that never recovers keeps the target order resting indefinitely.

The momentum breakout buys after a +10% four-week burst and uses a 10% trailing stop for the exit. The trend with trailing stop enters above the 200-day average and exits only when a 15% trailing stop is hit. Those are stop legs with no profit leg. The momentum breakout had a median CAGR of 0% and a median drawdown of 20.1%, and the trailing-stop trend rule had a median CAGR of 2.61% and a median drawdown of 31.15%. They beat buy-and-hold on 21 and 20 funds respectively.

Adding a target to a trailing-stop rule, or a stop to a target rule, would create an OCO pair. The library has not tested that combination, and the medians above do not predict what it would do.

Rules that exit on a signal need no pair

Some templates exit on an indicator reading and keep no resting order at all. The RSI(2) snapback buys 2-day RSI readings under 10 and exits when RSI(2) recovers above 70. Its median CAGR was 4.74%, its median drawdown was 17.47%, and it made a median of 166 round trips. It beat buy-and-hold on 34 of 59 funds. Because the exit is a decision made at the close, there is no standing order to orphan.

The RSI mean reversion rule works the same way with the 14-day reading, buying under 30 and selling above 70. Its median CAGR was 2.98% and its median drawdown 24.63%, with a median of 15 round trips. The golden cross, the SMA 10/50 trend, the EMA 12/26 trend and the 200-day regime filter all hold while an average relationship is true and sell when it flips.

The design choice is a trade between two kinds of risk. A signal exit has no orphan risk and no resting order, and it can only act when the rule is evaluated. A resting exit acts the moment the market touches the level, even between evaluations, and it carries the order-management burden that OCO linking addresses. Both kinds appear among the templates, and the medians above show no clean winner by CAGR alone.

What the library backtests do and do not test

The engine evaluates daily-decision rules on minute-resolution consolidated US market data, and orders fill on minute bars. The headline run has no fees or slippage, with cost runs at 5 and 10 basis points. The start is $10,000 and there is no margin. Buy-and-hold puts 98% of the account in at the first open, as the templates do.

Several consequences follow for anything involving OCO orders. The engine sees one minute bar at a time, so when a single minute bar's range contains both the target and the stop, the order of the two touches inside that minute is not observable. A live broker sees the sequence tick by tick. The two legs of a pair can both be inside one bar's range, and which fills first decides the trade.

The test also stops at the order type. The 59 funds and 12 templates give a measured picture of how far apart exits sit and how often a rule reached them. They do not give a measured picture of what a linked pair would have done, because no template places both legs, and they say nothing about a broker's handling of partial fills or its cancel latency. All of the results are hypothetical and cover one window of 5.74 years.

Frequently asked questions

What does OCO mean in trading?

OCO means one-cancels-other. Two orders are linked so that when one fills, the broker cancels the other. It is most often used to pair a take-profit limit order with a stop-loss order on the same shares.

Why do traders use an OCO order?

The pair covers two outcomes with one instruction: the price reaches the target, or it falls to the stop. Without the link, a filled stop can leave a sell limit resting, and that limit can later execute against shares the account no longer holds.

What is the difference between an OCO order and a bracket order?

A bracket order contains an OCO pair and also includes the entry order. The [bracket order](/learn/glossary/bracket-order/) page covers the three-order structure. An OCO pair can be placed on a position that already exists, with no entry attached.

Can an OCO order leave me short?

A pair that is correctly linked cannot, because the filled leg cancels the other. Two separate exit orders can. If the stop sells the whole position and the limit stays live, a later fill on the limit sells shares the account does not hold.

Does the stop leg of an OCO order fix the exit price?

No. The stop triggers at a level and usually becomes a market order, so the fill can land below the level in a gap. TQQQ averaged a 1.78% overnight gap over the window, and SPY averaged 0.44%, so the distance a fill can land from the stop depends heavily on the fund.

Do the strategy backtests in the Learn library use OCO orders?

No template places a target and a stop together. The weekly 7% target and the dip buyer use a profit target, and the momentum breakout and trend with trailing stop use trailing stops. The library has not backtested a linked pair, and its results are hypothetical.

Run a strategy that uses this yourself, free →

Build it from blocks (or type it in English), backtest it on 5.7 years of minute data in seconds, tweak any parameter, then paper trade it on live data. No card, no broker needed to start.

Related terms

Bracket OrderAn entry order packaged with both of its exits: a take-profit above an…Stop-Loss OrderA resting order that triggers a sale when price falls to a set level, …

Backtests are hypothetical, computed by DeployQuant's engine on minute-resolution consolidated US market data (2021-01-04 to 2026-10-02, $10,000 starting capital, no margin, no fees or slippage in the headline run; buy-and-hold puts 98% of the account in at the first open, as the templates do) and do not guarantee future results. Nothing on this page is investment advice. Live trading involves risk of loss.