Most retail trading bots don't have proper exit logic. They have entry signals and hope. Automating stops and take-profits is what separates bots that survive from bots that don't.
This article walks through the basic exit toolkit, how to implement it on LMEX in Python, and the placement decisions that matter.
A trader who manually manages exits has two problems: they sleep, and they have emotions. Both produce worse outcomes than a bot that follows fixed rules without negotiation.
A 24/7 crypto market doesn't care about your sleep schedule. A position you open at 9pm can lose half its value by 6am if you're not watching. Automated stops handle this.
Manual exits also tend to be biased: cutting winners early (taking small profits), letting losers run (hoping for recovery). Automation removes this bias entirely. The rule fires regardless of how you feel about the trade.
Four exit mechanisms cover 95% of use cases:
**Stop loss** — hard exit at a worse price than entry. Bounds maximum loss per trade. The most important exit.
**Take profit** — hard exit at a better price than entry. Locks in gains at a predetermined level.
**Trailing stop** — moves with price in favour of the position, never against. Captures unrealised gains while letting winners run.
**OCO (One-Cancels-Other)** — places both stop and take profit; when either fills, the other cancels automatically. Eliminates "double exit" risk.
A well-designed bot uses all four depending on the strategy. Some strategies use only stops (momentum). Some use trailing stops (trend-following). Some use OCO (mean reversion with defined targets).
LMEX supports stop orders, take profits, and OCO natively. Through CCXT:
`reduceOnly: True` ensures the exit orders only close existing positions, never open new ones. This prevents stops from accidentally creating positions in volatile conditions.
The above places stop and take profit as separate orders. If the stop fills, you need to manually cancel the take profit (and vice versa) to avoid having a stray order sitting in the book.
True OCO via CCXT:
Always prefer OCO when supported. It removes the manual-cancellation step that's a common source of bugs.
The wrong stop placement is worse than no stop. Three common approaches:
**ATR-based** — use 2× the Average True Range as the stop distance. Adapts to current volatility automatically. When markets are calm, stops are tight; when volatile, stops are wider. Most robust default.
**Percentage-based** — fixed percentage from entry (e.g., 2% below for longs). Simple but doesn't adapt to volatility. Works fine for low-volatility assets, terrible for crypto.
**Structure-based** — place stop just beyond the most recent swing low (for longs) or swing high (for shorts). Respects market structure. Better for swing trading than HFT.
For most retail bots, ATR-based with a 2× multiplier is the sweet spot. Tight enough to bound risk, wide enough to avoid noise stops.
A single take profit at a fixed target is suboptimal. Better: ladder partial exits at multiple targets.
A typical ladder for a long position:
This captures partial gains early (psychological win), leaves room for big winners, and lets the trailing stop handle the runner.
Ladders work best for strategies with high reward potential and lower win rate (trend following, breakouts). For high win-rate strategies (mean reversion), simpler single-target exits are usually better.
Q: How tight should my stops be?
Tight enough to bound risk, wide enough to avoid noise. 2× ATR is the standard default. Tighter than 1× ATR produces excessive whipsaws. Wider than 3× ATR exposes too much capital per trade.
Q: Should I use stop-market or stop-limit orders?
Stop-market for protection (guaranteed fill at any price, may slip during flash crashes). Stop-limit for precision (fills only at your specified price, may not fill at all in extreme moves). For risk management, prefer stop-market — slippage is better than not exiting.
Q: How do I handle stops being hunted during volatile periods?
Wider stops, smaller positions. The position sizing math means risking the same dollar amount per trade regardless of stop width. A wider stop with smaller position size has the same risk as a tight stop with larger position — but avoids being stopped on noise.
Q: Can I move stops as the trade progresses?
Only in your favour. Move stops to breakeven when the trade has run 1× ATR in profit. Move to lock in partial profit at 2× ATR. Never widen a stop because the trade went against you — that's the path to large losses.