OPEN-SOURCE SCRIPT
Aggiornato

MADZ - Moving Average Deviation Z-Score

413
MADZ - Moving Average Deviation Z-Score

MADZ is a powerful valuation oscillator that measures how far the current price has deviated from a user-selected moving average, expressed in statistical terms as a Z-Score. This normalization makes it easier to identify overvalued and undervalued conditions across different assets, timeframes, and market environments.

Overview

The indicator works by:
Calculating the percentage deviation of price from a customizable moving average (SMA, EMA, WMA, VWMA, HMA, or RMA).

Applying a Z-Score transformation to this deviation over a chosen lookback period — showing how many standard deviations the current deviation is from its historical average. Smoothing the result for a clean, responsive oscillator centered around zero.

Positive values indicate price is trading above the moving average (potentially overvalued), while negative values suggest price is below (potentially undervalued). The further from zero, the greater the relative valuation extreme.

Key Features

  • Customizable base moving average (type and length)
  • Z-Score normalization for statistically meaningful readings
  • Final smoothing for reduced noise
  • Static overbought/oversold levels (default ±1.5) — line changes color when crossed (red above, green below)
  • Dynamic extreme bands (±3σ) — optional display of bands calculated from the oscillator’s own volatility over a user-defined period
  • Extreme zone highlighting — background shading activates only during truly rare valuation events


Extreme Zone Highlighting Explained

The highlighted extreme zones (background shading) are not based on the fixed static levels. Instead, they signal statistically significant outliers using dynamic bands:

Overbought extreme zone (red background): Triggered when MADZ rises above the upper dynamic band (+3 standard deviations of the MADZ line itself over the dynamic length period).

Oversold extreme zone (green background): Triggered when MADZ falls below the lower dynamic band (-3 standard deviations).

These ±3σ bands adapt to the recent behavior of the oscillator. Because they represent three standard deviations from the mean of MADZ, crossings are rare and often precede major reversals or trend accelerations — making them valuable for spotting potential turning points in valuation extremes.

How to Use

  • Use zero-line crosses for trend changes or mean-reversion setups.
  • Watch static level crossings (±1.5 default) for early overbought/oversold warnings.
  • Pay special attention to extreme zone shading — these highlight high-conviction valuation dislocations that may offer superior risk/reward opportunities.
  • Designed on the BTC chart, but can be used on other assets.


Settings

  • Moving Average Settings: Type, length, source
  • Z-Score & Smoothing: Lookback period and smoothing length
  • Threshold Levels: Static overbought/oversold thresholds
  • Display Options: Toggle dynamic bands and extreme background highlighting


This is an educational tool designed to aid in valuation analysis. The information provided is not financial advice. Always conduct your own research and consider multiple factors before making trading decisions. Trade at your own risk.
Note di rilascio
Removed unnecessary code.

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.