Smart OCO - Position-Aware Order Monitoring
Premium FeatureAdvanced OCO monitoring that tracks position state instead of individual order events, enabling sophisticated exit strategies.
What Makes Smart OCO Premium
While standard OCO is perfect for simple binary exits (TP or SL), Smart OCO extends this with position-aware monitoring for advanced scenarios like multi-level exit ladders and automatic flip cleanup.
Understanding the Difference
Standard OCO
Event-BasedPerfect for:
• Simple binary outcomes (TP or SL)
• Single TP/SL pairs
• Order-event cleanup
• Maximum simplicity
Monitors:
Individual order fills/cancels
Trigger:
When a primary tracked order closes or is cancelled → Cancel the remaining group
Smart OCO
Position-BasedPerfect for:
• Multi-level exit ladders
• Partial take profit strategies
• Position flip scenarios
• Complex exit management
Monitors:
Position size and side
Trigger:
When position conditions met → Cleanup
Both modes are valid tools - choose based on your strategy complexity. Standard OCO excels at simplicity, Smart OCO enables advanced scenarios.
How Smart OCO Works
Smart OCO runs a background monitor polling your position state with two configurable conditions:
Cleanup on Position Close
When position closes to zero → Automatically cancel remaining orders. Perfect for exit ladders that complete fully.
Cleanup on Position Flip
When position changes side (LONG→SHORT) → Cancel old exit orders. Essential for multi-signal strategies.
Syntax
Basic (default: both conditions enabled)
smart-oco sellAdvanced Configuration
smart-oco sell cancelOnZero=true cancelOnFlip=false
smart-oco sell cancelOnZero=false cancelOnFlip=true
smart-oco all
smart-oco #exitsReal-World Use Cases
1. Three-Level Exit Ladder
Gradual position exit while maintaining stop loss protection throughout
ADAUSDT on Binance_F_Demo
// Entry with protection
market long 100
stoploss off 1.5%
// Three-level exit ladder
// TP1: +3%
takeprofit 30%p off rr2
// TP2: +4.5%
takeprofit 30%p off rr3
// TP3: +6%
takeprofit 40%p off rr4
smart-oco sellIf size was unchanged at placement: TP1 fills → Exit 30 → Position = 70 → All orders remain active
TP2 fills → Exit 30 → Position = 40 → SL + TP3 remain active
TP3 fills → Exit 40 → Position = 0 → Smart OCO cancels SL
2. Multi-Signal Strategy with Flips
Trading system that can reverse positions based on new signals
BTCUSDT on My_API_Key
// Initial signal in one-way mode
market long 0.01
stoploss off 1%
takeprofit 50%p rr2
takeprofit 50%p rr3
smart-oco sellSeparate reversal alert, only after checking the position is still long 0.01 BTC in one-way mode. Two alerts are not atomic; inspect fills and old-order cleanup before adding new protections.
BTCUSDT on My_API_Key
market short 0.02Cleanup is requested after the position condition is observed. Verify cancellation results before relying on a new setup.
Comparison Matrix
| Feature | Standard OCO | Smart OCO |
|---|---|---|
| Monitoring | Order events | Position state |
| Trigger | Order fills/cancels | Position conditions |
| Partial Exits | First exit cancels all | Maintains monitoring |
| Exit Ladders | Not supported | Fully supported |
| Flip Detection | Not applicable | Automatic cleanup |
| Latency | Native linkage or polling | Depends on polling and exchange responses |
| Complexity | Simple | Advanced |
| Best For | Binary outcomes | Complex strategies |
Choosing the Right Tool
Choose Standard OCO when:
- Single TP and single SL
- Binary outcome (TP or SL)
- No partial exits planned
- Maximum simplicity preferred
market long 100
stoploss off 1%
takeprofit off 3%
oco sellChoose Smart OCO when:
- Multiple TP levels (ladder)
- Position may flip/reverse
- Gradual exit strategy
- Advanced position management
market long 100
stoploss off 1%
takeprofit 33%p off rr2
takeprofit 33%p off rr3
takeprofit 34%p off rr4
smart-oco sellBest Practices
Use Position Percentage (%p) for Exit Ladders
// Percentages are calculated when orders are placed
takeprofit 33%p off rr2
takeprofit 33%p off rr3
takeprofit 34%p off rr4
// A fixed quantity is another choice; check units and remaining size
takeprofit 30 off rr2Test in Demo/Testnet First
BTCUSDT on Binance_F_Demo
// Safe: Always test first
// Production: Only after testing
BTCUSDT on Binance_FUnderstand the Defaults
When in doubt, use default (both conditions enabled). It provides comprehensive automation for most scenarios.
Performance Characteristics
Cancellation timing: Depends on polling and exchange responses from event to order cancellation
Acceptable For:
- • Discretionary trading
- • Swing trading (hours/days)
- • Day trading (intraday)
- • Scalping (depends on style)
Not Ideal For:
- • Sub-second latency requirements
- • High-frequency trading (HFT)
- • Market making
Frequently Asked Questions
Q: Is Smart OCO slower than Standard OCO?
A: Standard and Smart OCO use different triggers. Software monitoring depends on polling and exchange responses; native OCO is handled by the exchange. Neither software mode promises an instantaneous cancellation.
Q: Can I use both Standard and Smart OCO simultaneously?
A: Yes, absolutely. They are completely independent. You can have Standard OCO on one symbol and Smart OCO on another.
Q: What happens if the server restarts?
A: Smart OCO groups are persisted in the database. On restart, the monitor automatically reloads all active groups and continues monitoring. The restart leaves a monitoring gap; exchange orders already accepted remain subject to exchange rules.
Q: Does Smart OCO work on all exchanges?
A: Availability depends on the exchange, market, order types and plan. Check Exchange Quirks and the supported choices in API Keys; native position TP/SL may not appear as ordinary open orders.
Last updated: 2025-11-17