Core idea
A fixed stop-loss is set once and stays there. A trailing stop moves along with the price — but only in one direction.
For long positions: - Price rises by X → the stop moves up by X. - Price falls → the stop stays put. - Price falls to the stop → exit.
The result: the position stays open as long as the trend runs, and is closed exactly when the market turns — but never with a worse exit than the current trailing level.
How the distance is determined
- Fixed percentage — e.g. 3% below the current high.
- ATR-based — stop = high − n · ATR. Adapts automatically to volatility. Popular thanks to Chuck LeBeau (Chandelier Exit).
- Structure-based — stop below the last swing low.
- Parabolic SAR — stops accelerate the longer the trend runs.
How Botty implements it
execution/trader.py manages trailing stops in-process: on each tick it checks whether the current high/low improves the trail level. If so, the old stop is cancelled on Hyperliquid and a new one is placed (an atomic modification would be ideal, but the API does not support it — hence cancel + replace).
config.py → ATR_TRAIL_MULTIPLIER determines the distance. Typical: 2.0–3.0 ATR.
Trade-offs
✅ Lets profits run without any discipline risk. ✅ Works significantly better in trends than fixed targets.
❌ In sideways markets you get stopped out frequently. ❌ Large volatility (wicks) can shake you out even with a generous stop — a spike kills the position, price immediately reverses, the pain is large. ❌ The chosen distance is a genuinely important knob: too tight = whipsaw, too wide = profit given away.