OPEN-SOURCE SCRIPT
Statistical Price Deviation Index (MAD/VWMA)

SPDI is a statistical oscillator designed to detect potential price reversal zones by measuring how far price deviates from its typical behavior within a defined rolling window.
Instead of using momentum or moving averages like traditional indicators, SPDI applies robust statistics - a rolling median and Mean Absolute Deviation (MAD) - to calculate a normalized measure of price displacement. This normalization keeps the output bounded (from −1 to +1 by default), producing a stable and consistent oscillator that adapts to changing volatility conditions.
The second line in SPDI uses a Volume-Weighted Moving Average (VWMA) instead of a simple price median. This creates a complementary oscillator showing statistically weighted deviations based on traded volume. When both oscillators align in their extremes, strong confluence reversal signals are generated.
How It Works
How to Use
Settings Tips
Summary:
SPDI transforms raw price and volume data into a statistically bounded deviation index. When both Price MAD and VWMA Disp reach joint extremes, it highlights probable market turning points - offering traders a clean, data-driven way to spot potential reversals ahead of time.
Instead of using momentum or moving averages like traditional indicators, SPDI applies robust statistics - a rolling median and Mean Absolute Deviation (MAD) - to calculate a normalized measure of price displacement. This normalization keeps the output bounded (from −1 to +1 by default), producing a stable and consistent oscillator that adapts to changing volatility conditions.
The second line in SPDI uses a Volume-Weighted Moving Average (VWMA) instead of a simple price median. This creates a complementary oscillator showing statistically weighted deviations based on traded volume. When both oscillators align in their extremes, strong confluence reversal signals are generated.
How It Works
- For each bar, SPDI calculates the median price of the last N bars (default 100).
- It then measures how far the current bar’s midpoint deviates from that rolling median.
- The Mean Absolute Deviation (MAD) of those distances defines a “normal” range of fluctuation.
- The deviation is normalized and compressed via a tanh mapping, keeping the oscillator in fixed boundaries (−1 to +1).
- The same logic is applied to the VWMA line to gauge volume-weighted deviations.
How to Use
- The blue line (Price MAD) represents pure price deviation.
- The green line (VWMA Disp) shows the volume-weighted deviation.
- Overbought (red) zones indicate statistically extreme upward deviation -> potential short-term overextension.
- Oversold (green) zones indicate statistically extreme downward deviation -> potential rebound area.
- Confluence signals (both lines hitting the same extreme) often mark strong reversal points.
Settings Tips
- Lookback length controls how much historical data defines “normal” behavior. Larger = smoother, smaller = more sensitive.
- Smoothing (RMA length) can reduce noise without changing the overall statistical logic.
- Output scale can be set to either −1..+1 or 0..100, depending on your visual preference.
- Alerts and color fills are fully customizable in the Style tab.
Summary:
SPDI transforms raw price and volume data into a statistically bounded deviation index. When both Price MAD and VWMA Disp reach joint extremes, it highlights probable market turning points - offering traders a clean, data-driven way to spot potential reversals ahead of time.
Skrypt open-source
W duchu TradingView twórca tego skryptu udostępnił go jako open-source, aby traderzy mogli analizować i weryfikować jego funkcjonalność. Brawo dla autora! Możesz korzystać z niego za darmo, ale pamiętaj, że ponowna publikacja kodu podlega naszym Zasadom Społeczności.
Wyłączenie odpowiedzialności
Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.
Skrypt open-source
W duchu TradingView twórca tego skryptu udostępnił go jako open-source, aby traderzy mogli analizować i weryfikować jego funkcjonalność. Brawo dla autora! Możesz korzystać z niego za darmo, ale pamiętaj, że ponowna publikacja kodu podlega naszym Zasadom Społeczności.
Wyłączenie odpowiedzialności
Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.