OPEN-SOURCE SCRIPT

ATR-Based Z-Score (with Signal Line)

96
The ATR-Based Z-Score is an advanced, volatility-normalized oscillator designed to identify extreme price deviations more reliably than the standard Z-Score.

By replacing the traditional Standard Deviation with the Average True Range (ATR) in the denominator, this indicator eliminates the "volatility paradox" where rapid price spikes cause standard oscillators to prematurely return to zero, even as the price continues to crash.

Why this version is superior
In a classic Z-Score calculation:
Z = (Price - SMA) / (Standard Deviation)

A sudden impulsive price drop causes the Standard Deviation to explode. Because you are dividing by a rapidly increasing number, the Z-Score often "rises" while the price is still falling.

The ATR-Based Solution:
Z = (Price - SMA) / ATR

By using a long-period ATR as the denominator, the volatility measure remains stable and "clean." This ensures that the indicator’s troughs align much more accurately with actual price bottoms, staying in the oversold territory until the momentum truly shifts.

Key Features
  • Volatility Cleaning: The ATR-normalization prevents the indicator from "flattening out" during impulsive price movements.
  • Integrated Signal Line: A customizable Moving Average of the Z-Score values helps filter noise and confirms entry/exit points.
  • Independent Periods: You can set the Price MA (responsiveness) and the ATR (volatility baseline) separately to fine-tune the indicator to different timeframes.


How to Trade with it
1. Mean Reversion (Buy the Dip / Sell the Rip)
  • Long: Wait for the Z-Score to drop below a significant level (e.g., -10.0). Enter when the Z-Score crosses back above its Signal Line.
  • Short: Wait for the Z-Score to rise above +10.0 and enter when it crosses below the Signal Line.

2. Breakout Trading
  • A strong push of the Z-Score beyond the +/- 7.0 levels can indicate a powerful trend breakout.
  • In this case, the Signal Line crossover serves as an effective Exit Signal, telling you that the initial momentum of the breakout is fading.


Summary
✅ This indicator is designed for traders who find standard oscillators too "nervous" during volatile periods. By decoupling price deviation from immediate variance spikes, the ATR-Based Z-Score provides a rock-solid foundation for identifying true market extremes and high-probability reversal points.

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.