OCO Orders Explained
An OCO order is two orders linked so that when one fills, the other is automatically cancelled. The standard use is bracketing an existing position with a profit target and a stop loss: whichever is reached first executes, and the linkage removes the other so you are not left holding an unwanted order. Without the linkage, both orders remain live independently, and a fill on one leaves the other exposed to executing later and opening a position you did not intend.
One-cancels-other is a simple mechanism with a specific job, and it is worth understanding precisely because the failure it prevents is easy to overlook until it happens.
The mechanic
Two orders are submitted as a linked pair. Both rest at the broker. When either executes, the broker cancels the other.
For a long position, that pair is typically a sell limit above the market as a profit target and a sell stop below it as protection. The position exits at whichever is reached first, and only one of them can execute.
The linkage is the entire feature. Two orders without it are just two orders.
What goes wrong without linkage
Consider a long position with an unlinked target and stop. The target fills. The position is now flat.
The stop is still resting at the broker, and it does not know anything changed. If price subsequently falls to the stop level, it triggers and sends a sell order. You are now short a position you never intended to open, and you may not discover it until you look.
This is the specific hazard OCO exists to eliminate. It is not a convenience feature; it is protection against holding a live instruction that has outlived its purpose.
The same failure occurs in reverse when the stop fills and the target remains resting above the market.
Partial fills complicate it
Where OCO gets less clean, and where implementations differ.
If a target for ten contracts fills only four, the position is not flat. Reasonable handling reduces the paired stop to the remaining six. Whether a given broker does that automatically, and how quickly, is broker-specific behaviour rather than a property of OCO as a concept.
For any automated system this is worth verifying directly rather than assuming, because the failure mode is a stop covering more contracts than you hold, which on a trigger converts a flat position into a short one.
OCO, OTO, and OTOCO
Three related structures that get conflated.
OCO links two orders for a position that already exists. There is no entry component.
OTO is one-triggers-other: a primary order that, on execution, submits one or more subsequent orders. The subsequent orders do not exist until the primary fills.
OTOCO combines them: an entry order that, when filled, creates a target and a stop which are themselves OCO-linked. This is the full bracket, and it is what most automated entries actually want, because the exits come into existence at the same moment the position does.
The distinction matters for automation. OCO requires you to already hold the position, which means a separate step after entry β and any separate step is a step that can fail to happen. OTOCO removes that gap.
Where OCO is used
Bracketing an existing position is the primary case, and the reason the structure exists.
Scaling out uses several OCO pairs at different price levels covering portions of a position, though the partial-fill considerations above apply with more force.
Multi-leg exits apply the same idea to spreads, where the target and stop each reference the package rather than individual legs.
Breakout entries in either direction are the less obvious case: a buy stop above the market and a sell stop below it, linked so that whichever direction resolves first cancels the other. Useful before a known catalyst, and it carries its own risk β in a fast move both levels can be reached in quick succession, and the cancellation is not instantaneous.
Broker-resident versus software-managed
The important distinction for anyone automating.
A broker-resident OCO rests at the broker and the broker enforces the linkage. It survives your software crashing, your host rebooting, and your network dropping. If your process dies with a position open, the exits are still there.
Software-managed exits β where your system watches the price and submits an order when its own condition is met β offer logic no broker provides, such as trailing rules that change through the position. They also stop existing when the process does.
For anything where an unmanaged position would be unacceptable, broker-resident exits are the safer default, and software can layer additional logic on top rather than replacing them.
One operational trap worth naming: cancelling a linked order group generally requires the broker's dedicated complex-order cancellation call. The ordinary cancel can remove individual components without erroring, which silently dismantles half a bracket and leaves the other half live. That is a stop removed while a target remains, with no error message anywhere.
The honest limits
OCO guarantees that one order is cancelled when the other fills. It guarantees nothing about price.
The stop side remains a stop: FINRA is explicit that a stop price is not a guaranteed execution price, and a stop-limit may never execute at all.
Cancellation is not instantaneous. In a fast market both legs can be reached before the cancel propagates, and while brokers handle this, the possibility is real rather than theoretical.
During a trading halt neither side can execute, and Cboe cancels all open option orders when the underlying enters a pause β so an options OCO can simply cease to exist mid-position.
And a bracket does not size a position. Position sizing determines what a bad exit costs, which is why the divide-by-20 rule sits upstream of every order type here: capital divided by twenty as the ceiling per position. On a self-hosted deployment that limit is enforced in your own environment, where a malformed signal cannot reach it, while the order path itself stays fast enough that submitting the bracket is not the slow step.
Frequently asked questions
What does OCO mean? One-cancels-other: two linked orders where the execution of one automatically cancels the other.
What is OCO used for? Most commonly bracketing an existing position with a profit target and a stop loss so that only one can execute.
What is the difference between OCO and OTOCO? OCO links exits for a position you already hold. OTOCO adds an entry order that creates the OCO-linked exits when it fills.
What happens on a partial fill? The paired order should be reduced to the remaining quantity. Whether that happens automatically is broker-specific and worth verifying.
Does OCO guarantee my exit price? No. The stop side is still a stop, and a stop price is not a guaranteed execution price.
Disclaimer: This article is educational content about trading mechanics and software engineering. It is not investment advice, financial advice, tax advice, legal advice, or a recommendation to buy or sell any security, nor a recommendation of any strategy, order type, or configuration. Any instruments, settings, or figures named are used solely to illustrate mechanics. Options trading involves substantial risk of loss and is not suitable for all investors. Please read Characteristics and Risks of Standardized Options before trading options. Automated trading systems carry additional risks including software defects, connectivity failures, broker API changes, and outages that may prevent orders from being placed, modified, or cancelled. Stop orders do not guarantee an execution price and stop-limit orders may not execute at all. Past performance does not indicate future results, and no configuration, order type, position-sizing rule, or risk setting can guarantee a profit or prevent a loss.
StaxInvesting LLC sells self-hosted trading software. It is not a broker-dealer, investment adviser, or financial institution, and it does not manage accounts, hold member funds, place trades on behalf of members, or access member brokerage accounts. Members run the software in their own cloud environment, connect their own brokerage accounts under their own credentials, and are solely responsible for their configuration, their credential security, and every trade executed in their account. Third-party platform and broker details described here reflect publicly available information as of publication and are subject to change without notice; always verify against current official documentation. Consult a qualified financial adviser and tax professional regarding your individual circumstances.