OPEN-SOURCE SCRIPT
MAD Supertrend ~ C H I P A

MAD Supertrend ~ C H I P A is a custom trend-following system that replaces the standard deviation core of a classic Supertrend with Median Absolute Deviation (MAD) — a robust volatility measure that ignores outlier wicks instead of inflating on them. The result is a trail that holds steady through shakeout spikes where stdev-based bands blow out and go blind.
It uses:
A user-selectable source and MAD length
A choice of MAD estimator — true Median-of-deviations for maximum robustness, or Mean for a slightly smoother read
Independent upper and lower MAD multipliers for asymmetric band control
A selectable centerline engine: raw Source for zero lag, Single Median, or a Double Median smoother that kills staircase artefacts without adding meaningful delay
A PSAR-style exit acceleration module — each new closing extreme in the trend tightens the exit trail by a configurable step, down to a user-defined floor
Supertrend ratchet logic with persistent trend state and clean flip detection
The exit acceleration is the key behavioural difference from a standard Supertrend: fresh trends begin at full band width, giving early moves room to survive shakeouts, while mature trends that keep printing new extremes are trailed progressively tighter — so extended runs are exited far closer to their peak. The trail only ever tightens mid-trend and fully resets on each flip.
Alerts fire on confirmed trend flips in both directions.
Note: MAD Supertrend is provided "as is" without formal robustness or optimization testing. Past performance is not indicative of future results; use in live trading only after sufficient back-testing and validation.
It uses:
A user-selectable source and MAD length
A choice of MAD estimator — true Median-of-deviations for maximum robustness, or Mean for a slightly smoother read
Independent upper and lower MAD multipliers for asymmetric band control
A selectable centerline engine: raw Source for zero lag, Single Median, or a Double Median smoother that kills staircase artefacts without adding meaningful delay
A PSAR-style exit acceleration module — each new closing extreme in the trend tightens the exit trail by a configurable step, down to a user-defined floor
Supertrend ratchet logic with persistent trend state and clean flip detection
The exit acceleration is the key behavioural difference from a standard Supertrend: fresh trends begin at full band width, giving early moves room to survive shakeouts, while mature trends that keep printing new extremes are trailed progressively tighter — so extended runs are exited far closer to their peak. The trail only ever tightens mid-trend and fully resets on each flip.
Alerts fire on confirmed trend flips in both directions.
Note: MAD Supertrend is provided "as is" without formal robustness or optimization testing. Past performance is not indicative of future results; use in live trading only after sufficient back-testing and validation.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.
Script open-source
Nello spirito di TradingView, l'autore di questo script lo ha reso open source, in modo che i trader possano esaminarne e verificarne la funzionalità. Complimenti all'autore! Sebbene sia possibile utilizzarlo gratuitamente, ricordiamo che la ripubblicazione del codice è soggetta al nostro Regolamento.
Declinazione di responsabilità
Le informazioni e le pubblicazioni non sono intese come, e non costituiscono, consulenza o raccomandazioni finanziarie, di investimento, di trading o di altro tipo fornite o approvate da TradingView. Per ulteriori informazioni, consultare i Termini di utilizzo.