Development of Stop-Loss Management System
Stop-loss management is not just placing an order. It's a decision-making system for placement, relocation, and execution of protective orders throughout the entire position lifecycle.
Initial Stop Placement Strategies
ATR-based: stop at N × ATR below entry. N = 1.5–2.5 depending on strategy. Adapts to volatility.
Structure-based: stop behind nearest structural level (swing low/high, support/resistance). Logically justified: if structural level is broken, the trade idea is invalid.
Volatility-based (Chandelier): stop at N × ATR below position maximum. Automatically trailing.
Percentage-based: simple fixed % from entry. Less adaptive, but simple.
Stop Relocation
Break-even: after reaching TP1 or N% profit, move stop to entry point. "Free ride" position.
class StopLossManager:
def __init__(self, entry_price, initial_stop, side='long'):
self.entry_price = entry_price
self.stop_price = initial_stop
self.side = side
self.state = 'initial' # initial, break_even, trailing
def check_breakeven_trigger(self, current_price, breakeven_trigger_pct=0.015):
if self.side == 'long' and self.state == 'initial':
profit_pct = (current_price - self.entry_price) / self.entry_price
if profit_pct >= breakeven_trigger_pct:
self.stop_price = self.entry_price
self.state = 'break_even'
return True
return False
def update_trailing_stop(self, current_price, highest_price, trail_pct=0.02):
if self.state in ('break_even', 'trailing'):
new_stop = highest_price * (1 - trail_pct)
if new_stop > self.stop_price:
self.stop_price = new_stop
self.state = 'trailing'
Hard vs Soft Stop
Hard stop: limit or market order on exchange. Executes automatically without bot participation. More reliable, but may slip on fast move.
Soft stop: price monitoring in code, send order on level reach. More flexible (can apply logic), but depends on bot operability.
Recommendation: both simultaneously. Soft stop cancels Hard stop on normal operation. Hard stop is insurance against bot failure.
Gap Execution
On gap opening (price jumped through stop level):
- Limit stop may not execute
- Market executes at worst available price
- Stop-limit (specific order type): trigger by stop, execute by limit
Stop-limit setup: trigger = $44,000, limit = $43,500. Executes if price on gap doesn't go below $43,500. Otherwise remains as limit order on open position.
Stop Monitoring
Dashboard visualizing all open positions, their stops and distance to stop in %:
| Symbol | Entry | Stop | Distance | Status |
|---|---|---|---|---|
| BTC/USDT | $45,000 | $44,100 | 2.0% | Break-even |
| ETH/USDT | $3,200 | $3,000 | 6.25% | Initial |
Alert when price approaches stop at 50% of initial distance.
We develop stop management system with automatic break-even relocation, trailing stop, hard/soft stop support and monitoring all positions.







