OPEN-SOURCE SCRIPT
Median Gaussian SuperTrend | NAL

Median Gaussian SuperTrend is a trend-following framework that replaces the conventional SuperTrend volatility structure with a median-filtered Gaussian baseline and Gaussian-weighted deviation model.
The objective is to preserve the intuitive regime behavior of SuperTrend while producing a smoother underlying price structure and a volatility envelope that is less dependent on isolated observations.
Instead of building the trend state around ATR alone, the model combines median filtering, Gaussian smoothing, and Gaussian-weighted dispersion before converting the resulting bands into a trailing directional structure.
1. Median Gaussian Basis
The calculation begins by extracting the rolling median of the selected source. Median filtering reduces the influence of isolated price extremes before the series enters the Gaussian filter.
Pine Script®
The resulting baseline therefore represents a smoothed estimate of underlying price structure rather than a conventional moving average.
2. Gaussian Volatility Structure
Volatility around the baseline is estimated using a Gaussian-weighted deviation calculation.
Observations are not treated equally across the lookback window. Instead, the dispersion calculation uses Gaussian weights to construct both its weighted mean and weighted variance.
The resulting volatility estimate defines asymmetric upper and lower envelopes:
Pine Script®
Separate upper and lower multipliers allow the structure to be calibrated independently on each side of the market.
3. SuperTrend Conversion
The raw Gaussian bands are then transformed into persistent trailing boundaries using SuperTrend-style state logic.
The active boundary only resets when price structurally clears the opposing band. This converts the continuously changing Gaussian envelope into a discrete bullish or bearish trend regime.
Pine Script®
Visuals & Interpretation
Only the currently active SuperTrend boundary is displayed.
A directional gradient extends between the active boundary and the candle body, visually showing the relationship between price and the current trend structure without plotting the inactive side of the envelope.
Candles are colored according to the prevailing model state:
Three color presets — Standard, Nordic, and Simple — are included for chart customization.
Practical Application
Median Gaussian SuperTrend is designed as a clean directional framework for identifying trend state, structural transitions, and volatility-adjusted trailing levels.
The combination of median preprocessing and Gaussian weighting makes the model particularly useful when the goal is to extract persistent directional structure while reducing sensitivity to short-lived price disturbances.
The Gaussian length, sigma, volatility horizon, and independent upper/lower band multipliers can all be adjusted to control the model's responsiveness.
Automated Alerts
Built-in alerts are provided for both directional transitions:
For closed-bar signal confirmation, configure TradingView alerts to trigger Once Per Bar Close.
The objective is to preserve the intuitive regime behavior of SuperTrend while producing a smoother underlying price structure and a volatility envelope that is less dependent on isolated observations.
Instead of building the trend state around ATR alone, the model combines median filtering, Gaussian smoothing, and Gaussian-weighted dispersion before converting the resulting bands into a trailing directional structure.
1. Median Gaussian Basis
The calculation begins by extracting the rolling median of the selected source. Median filtering reduces the influence of isolated price extremes before the series enters the Gaussian filter.
The resulting baseline therefore represents a smoothed estimate of underlying price structure rather than a conventional moving average.
2. Gaussian Volatility Structure
Volatility around the baseline is estimated using a Gaussian-weighted deviation calculation.
Observations are not treated equally across the lookback window. Instead, the dispersion calculation uses Gaussian weights to construct both its weighted mean and weighted variance.
The resulting volatility estimate defines asymmetric upper and lower envelopes:
Separate upper and lower multipliers allow the structure to be calibrated independently on each side of the market.
3. SuperTrend Conversion
The raw Gaussian bands are then transformed into persistent trailing boundaries using SuperTrend-style state logic.
The active boundary only resets when price structurally clears the opposing band. This converts the continuously changing Gaussian envelope into a discrete bullish or bearish trend regime.
- Bullish — the lower Gaussian boundary becomes the active trailing structure.
- Bearish — the upper Gaussian boundary becomes the active trailing structure.
Visuals & Interpretation
Only the currently active SuperTrend boundary is displayed.
A directional gradient extends between the active boundary and the candle body, visually showing the relationship between price and the current trend structure without plotting the inactive side of the envelope.
Candles are colored according to the prevailing model state:
- Bullish color — Median Gaussian SuperTrend is in its bullish regime.
- Bearish color — Median Gaussian SuperTrend is in its bearish regime.
Three color presets — Standard, Nordic, and Simple — are included for chart customization.
Practical Application
Median Gaussian SuperTrend is designed as a clean directional framework for identifying trend state, structural transitions, and volatility-adjusted trailing levels.
The combination of median preprocessing and Gaussian weighting makes the model particularly useful when the goal is to extract persistent directional structure while reducing sensitivity to short-lived price disturbances.
The Gaussian length, sigma, volatility horizon, and independent upper/lower band multipliers can all be adjusted to control the model's responsiveness.
Automated Alerts
Built-in alerts are provided for both directional transitions:
- Bullish Flip — triggers when the active Median Gaussian SuperTrend changes from bearish to bullish.
- Bearish Flip — triggers when the active Median Gaussian SuperTrend changes from bullish to bearish.
For closed-bar signal confirmation, configure TradingView alerts to trigger Once Per Bar Close.
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
🔵 Access our best trading & investing tools, get a 30-day free trial today: whop.com/nordic-alpha-lab/
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。
开源脚本
秉承TradingView的精神,该脚本的作者将其开源,以便交易者可以查看和验证其功能。向作者致敬!您可以免费使用该脚本,但请记住,重新发布代码须遵守我们的网站规则。
🔵 Access our best trading & investing tools, get a 30-day free trial today: whop.com/nordic-alpha-lab/
免责声明
这些信息和出版物并非旨在提供,也不构成TradingView提供或认可的任何形式的财务、投资、交易或其他类型的建议或推荐。请阅读使用条款了解更多信息。