OPEN-SOURCE SCRIPT
ATR Trailing Stop [Indicatr]

ATR Trailing Stop is a volatility-based trailing stop for long and short positions with a range filter that reduces whipsaw flips, plus a live readout of the stop distance in ATR and percent.
WHAT IT DOES
Fixed-percentage stops ignore volatility. ATR stops adapt to it, but in sideways markets they flip direction often. This script adds an ADX-based buffer that requires extra distance before flipping when the market is not trending.
HOW IT WORKS
HOW TO USE
THE CHART
ETHUSD daily with the chandelier stop (ATR 14 x 3, lookback 22). Green line = long stop, red line = short stop, triangles mark direction changes. The table in the top right shows the current stop distance.
WHAT IS ORIGINAL
Combines chandelier and midpoint ATR stops in one tool, adds an ADX-based flip buffer for range phases and a stop-distance readout. Position sizing is intentionally not included.
CREDITS
ATR and ADX (J. Welles Wilder), Chandelier Exit concept (Chuck LeBeau).
LIMITATIONS
Disclaimer
For educational and analytical purposes only. Not financial advice. Marks and signals are not buy or sell recommendations. Past behaviour does not guarantee future results.
WHAT IT DOES
Fixed-percentage stops ignore volatility. ATR stops adapt to it, but in sideways markets they flip direction often. This script adds an ADX-based buffer that requires extra distance before flipping when the market is not trending.
HOW IT WORKS
- Chandelier style: long stop = highest high (or close) of the lookback minus ATR x multiplier, short stop = lowest low plus ATR x multiplier.
- Midpoint style: hl2 plus/minus ATR x multiplier (Supertrend-like).
- Ratchet: the stop only moves in the direction of the trade.
- Flip: direction changes when price closes beyond the stop. With the range filter on and ADX below the threshold, price must close an additional distance (default 0.5 x ATR) beyond the stop.
- Table: direction, current stop distance (ATR and %), and whether the range filter is active.
HOW TO USE
- As a trailing exit for existing long or short positions, or as a volatility-based reference for initial stop placement.
- The stop distance readout helps compare risk across instruments.
- Alerts: turned long, turned short.
THE CHART
ETHUSD daily with the chandelier stop (ATR 14 x 3, lookback 22). Green line = long stop, red line = short stop, triangles mark direction changes. The table in the top right shows the current stop distance.
WHAT IS ORIGINAL
Combines chandelier and midpoint ATR stops in one tool, adds an ADX-based flip buffer for range phases and a stop-distance readout. Position sizing is intentionally not included.
CREDITS
ATR and ADX (J. Welles Wilder), Chandelier Exit concept (Chuck LeBeau).
LIMITATIONS
- Any trailing stop gives back part of a move before exiting.
- The range filter delays flips, which can mean a later exit when a real reversal starts.
- The stop can move on the current bar until it closes.
Disclaimer
For educational and analytical purposes only. Not financial advice. Marks and signals are not buy or sell recommendations. Past behaviour does not guarantee future results.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Indicatr - the indicators you know, rebuilt with market context: volume, trend and momentum, for long and short. Free open-source tools and Pro tools. Guides and setups: indicator.trading/en/link
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.
Open-source Skript
Ganz im Sinne von TradingView hat dieser Autor sein/ihr Script als Open-Source veröffentlicht. Auf diese Weise können nun auch andere Trader das Script rezensieren und die Funktionalität überprüfen. Vielen Dank an den Autor! Sie können das Script kostenlos verwenden, aber eine Wiederveröffentlichung des Codes unterliegt unseren Hausregeln.
Indicatr - the indicators you know, rebuilt with market context: volume, trend and momentum, for long and short. Free open-source tools and Pro tools. Guides and setups: indicator.trading/en/link
Haftungsausschluss
Die Informationen und Veröffentlichungen sind nicht als Finanz-, Anlage-, Handels- oder andere Arten von Ratschlägen oder Empfehlungen gedacht, die von TradingView bereitgestellt oder gebilligt werden, und stellen diese nicht dar. Lesen Sie mehr in den Nutzungsbedingungen.