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.
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.
🔵 Access our best trading & investing tools, get a 30-day free trial today: whop.com/nordic-alpha-lab/
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.
🔵 Access our best trading & investing tools, get a 30-day free trial today: whop.com/nordic-alpha-lab/
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.