OPEN-SOURCE SCRIPT
Ultimate Supertrend

1. The Core: NLMS Adaptive Filter
At its heart is the Normalized Least Mean Squares (NLMS) filter. Unlike a standard moving average (SMA/EMA) that statically averages the last X bars, the NLMS is an "online" machine-learning predictor.
It looks at the past M bars (taps) and uses gradient descent to calculate "weights" that best predict the current price.
The Step Size (μ) dictates how aggressively it learns. A higher step size makes it hug the price very closely (reactive), while a lower step size keeps the baseline smooth.
This creates an incredibly adaptive baseline that tracks market movement more intelligently than traditional moving averages.
2. Volatility Bands (ATR)
Instead of just using the raw NLMS line, the script applies an Average True Range (ATR) multiplier on top of it.
It calculates an upper and lower boundary based on the ATR around the NLMS baseline.
If the baseline tries to move past these upper/lower extremes, the indicator "ratchets" or snaps the trailing line to the boundary.
This creates the characteristic "stair-step" trailing stop behavior you see in Supertrends.
3. Trend Direction & Signals
The indicator determines the trend by looking at the trajectory of the final NLMS-ATR trailing line:
Bullish Trend (Green): Triggered when the trailing line ticks upward (crosses over its previous value).
Bearish Trend (Red): Triggered when the trailing line ticks downward (crosses under its previous value).
It fires automated alert conditions (alertcondition) whenever these trend flips occur.
4. Visual Enhancements
To make it visually intuitive for trading, the script includes premium aesthetics:
Trend Candles: Automatically paints the actual price candles green or red depending on the current trend.
Gradient Fills: Fills the area between the price and the trailing line, fading softly towards the price to show momentum density.
Trail Glow: Adds a sleek visual glow (semi-transparent bands) around the trailing line itself.
In short, it’s a highly-responsive, volatility-adjusted trailing stop that uses an adaptive algorithm to filter out market noise while keeping you on the right side of the trend.
At its heart is the Normalized Least Mean Squares (NLMS) filter. Unlike a standard moving average (SMA/EMA) that statically averages the last X bars, the NLMS is an "online" machine-learning predictor.
It looks at the past M bars (taps) and uses gradient descent to calculate "weights" that best predict the current price.
The Step Size (μ) dictates how aggressively it learns. A higher step size makes it hug the price very closely (reactive), while a lower step size keeps the baseline smooth.
This creates an incredibly adaptive baseline that tracks market movement more intelligently than traditional moving averages.
2. Volatility Bands (ATR)
Instead of just using the raw NLMS line, the script applies an Average True Range (ATR) multiplier on top of it.
It calculates an upper and lower boundary based on the ATR around the NLMS baseline.
If the baseline tries to move past these upper/lower extremes, the indicator "ratchets" or snaps the trailing line to the boundary.
This creates the characteristic "stair-step" trailing stop behavior you see in Supertrends.
3. Trend Direction & Signals
The indicator determines the trend by looking at the trajectory of the final NLMS-ATR trailing line:
Bullish Trend (Green): Triggered when the trailing line ticks upward (crosses over its previous value).
Bearish Trend (Red): Triggered when the trailing line ticks downward (crosses under its previous value).
It fires automated alert conditions (alertcondition) whenever these trend flips occur.
4. Visual Enhancements
To make it visually intuitive for trading, the script includes premium aesthetics:
Trend Candles: Automatically paints the actual price candles green or red depending on the current trend.
Gradient Fills: Fills the area between the price and the trailing line, fading softly towards the price to show momentum density.
Trail Glow: Adds a sleek visual glow (semi-transparent bands) around the trailing line itself.
In short, it’s a highly-responsive, volatility-adjusted trailing stop that uses an adaptive algorithm to filter out market noise while keeping you on the right side of the trend.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.
Skrip sumber terbuka
Dalam semangat TradingView sebenar, pencipta skrip ini telah menjadikannya sumber terbuka, jadi pedagang boleh menilai dan mengesahkan kefungsiannya. Terima kasih kepada penulis! Walaupuan anda boleh menggunakan secara percuma, ingat bahawa penerbitan semula kod ini tertakluk kepada Peraturan Dalaman.
Penafian
Maklumat dan penerbitan adalah tidak bertujuan, dan tidak membentuk, nasihat atau cadangan kewangan, pelaburan, dagangan atau jenis lain yang diberikan atau disahkan oleh TradingView. Baca lebih dalam Terma Penggunaan.