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.
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。
オープンソーススクリプト
TradingViewの精神に則り、このスクリプトの作者はコードをオープンソースとして公開してくれました。トレーダーが内容を確認・検証できるようにという配慮です。作者に拍手を送りましょう!無料で利用できますが、コードの再公開はハウスルールに従う必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または承認する金融、投資、取引、またはその他の種類の助言もしくは推奨であることを意図したものではなく、またこれらに該当するものでもありません。詳細は利用規約をご覧ください。