OPEN-SOURCE SCRIPT
ATR Trailing Stoploss [Multi]

ATR Trailing Stoploss [Multi]
This indicator plots five ATR-based trailing stop lines on your chart at once, giving you a layered view of volatility-adjusted support and resistance instead of a single stop level.
What it does
Each line is a trailing stoploss derived from the Average True Range (ATR). For every line it takes the recent high, subtracts a multiple of ATR, and tracks the highest such value over a lookback window. The result is a stop level that sits below price in uptrends and adapts as volatility expands or contracts. Plotting five of them together lets you see short-term and long-term stops simultaneously — faster lines hug price for tight exits, slower lines define the broader trend structure.
Two modes
Multi-Period (default): All five lines are calculated on your current chart timeframe using different ATR lengths (5, 10, 20, 40, 80 by default). Every line updates on every candle and moves smoothly with the bars, so you get five sensitivities — from scalping-tight to position-wide — on a single timeframe.
Multi-Timeframe: Each line is instead pulled from a higher timeframe (e.g. 5m, 15m, 1H, 4H, Daily) via request.security. This shows where the stop sits on larger timeframes while you trade a smaller one. Note that, by nature, each higher-timeframe line appears as a flat step that only changes when its timeframe closes a bar.
Inputs
You can set the ATR length for each of the five lines, the HHV lookback period, and the ATR multiplier (shared across lines). In Multi-Timeframe mode you choose the timeframe for each line and can optionally allow the live higher-timeframe bar to update in real time (repaint) or restrict to confirmed values only (non-repainting, default).
Signals and bar coloring
Bars are colored green when price is above Line 1's stop and red when below. Buy/Sell labels and alerts trigger when price crosses Line 1, so you can attach TradingView alerts to the fastest stop while using the slower lines as trend context.
How to use it
Treat the lines as a stack of dynamic stops: price holding above the cluster signals a healthy trend, while breaks through successive lines flag weakening momentum. Use the tighter lines for trade management and the wider lines to gauge whether the larger trend is still intact.
This script is a tool for analysis and does not constitute financial advice. Always test on your own instruments and timeframes before trading.
This indicator plots five ATR-based trailing stop lines on your chart at once, giving you a layered view of volatility-adjusted support and resistance instead of a single stop level.
What it does
Each line is a trailing stoploss derived from the Average True Range (ATR). For every line it takes the recent high, subtracts a multiple of ATR, and tracks the highest such value over a lookback window. The result is a stop level that sits below price in uptrends and adapts as volatility expands or contracts. Plotting five of them together lets you see short-term and long-term stops simultaneously — faster lines hug price for tight exits, slower lines define the broader trend structure.
Two modes
Multi-Period (default): All five lines are calculated on your current chart timeframe using different ATR lengths (5, 10, 20, 40, 80 by default). Every line updates on every candle and moves smoothly with the bars, so you get five sensitivities — from scalping-tight to position-wide — on a single timeframe.
Multi-Timeframe: Each line is instead pulled from a higher timeframe (e.g. 5m, 15m, 1H, 4H, Daily) via request.security. This shows where the stop sits on larger timeframes while you trade a smaller one. Note that, by nature, each higher-timeframe line appears as a flat step that only changes when its timeframe closes a bar.
Inputs
You can set the ATR length for each of the five lines, the HHV lookback period, and the ATR multiplier (shared across lines). In Multi-Timeframe mode you choose the timeframe for each line and can optionally allow the live higher-timeframe bar to update in real time (repaint) or restrict to confirmed values only (non-repainting, default).
Signals and bar coloring
Bars are colored green when price is above Line 1's stop and red when below. Buy/Sell labels and alerts trigger when price crosses Line 1, so you can attach TradingView alerts to the fastest stop while using the slower lines as trend context.
How to use it
Treat the lines as a stack of dynamic stops: price holding above the cluster signals a healthy trend, while breaks through successive lines flag weakening momentum. Use the tighter lines for trade management and the wider lines to gauge whether the larger trend is still intact.
This script is a tool for analysis and does not constitute financial advice. Always test on your own instruments and timeframes before trading.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.
Skrip open-source
Dengan semangat TradingView yang sesungguhnya, pembuat skrip ini telah menjadikannya sebagai sumber terbuka, sehingga para trader dapat meninjau dan memverifikasi fungsinya. Salut untuk penulisnya! Meskipun Anda dapat menggunakannya secara gratis, perlu diingat bahwa penerbitan ulang kode ini tunduk pada Tata Tertib kami.
Pernyataan Penyangkalan
Informasi dan publikasi ini tidak dimaksudkan, dan bukan merupakan, saran atau rekomendasi keuangan, investasi, trading, atau jenis lainnya yang diberikan atau didukung oleh TradingView. Baca selengkapnya di Ketentuan Penggunaan.