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.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
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
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.
Mã nguồn mở
Theo đúng tinh thần TradingView, tác giả của tập lệnh này đã công bố nó dưới dạng mã nguồn mở, để các nhà giao dịch có thể xem xét và xác minh chức năng. Chúc mừng tác giả! Mặc dù bạn có thể sử dụng miễn phí, hãy nhớ rằng việc công bố lại mã phải tuân theo Nội quy.
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
Thông báo miễn trừ trách nhiệm
Thông tin và các ấn phẩm này không nhằm mục đích, và không cấu thành, lời khuyên hoặc khuyến nghị về tài chính, đầu tư, giao dịch hay các loại khác do TradingView cung cấp hoặc xác nhận. Đọc thêm tại Điều khoản Sử dụng.