OPEN-SOURCE SCRIPT

Z-Score Predictive Zones [AlgoPoint]

23 706
Z-Score Predictive Zones [AlgoPoint]

This indicator is an advanced evolution of the classic Z-Score (Standard Score) oscillator. Unlike traditional Z-Score indicators that use static overbought/oversold levels (e.g., +2.0 or -2.0), this script utilizes a dynamic memory system to identify where the market statistically tends to reverse based on recent history.

It provides a dual-view system: it displays the oscillator in the bottom pane and simultaneously projects those statistical extremes onto the main chart as Predictive Support and Resistance Zones.

1. Underlying Concept & Math
The core calculation is based on the Standard Score formula: Z = (Price - Mean) / Standard Deviation

- Adaptive Thresholds: The script detects pivot points (peaks and troughs) in the Z-Score history. It stores the most recent reversals (based on user-defined depth) and calculates the average level where the market has historically reversed.

- Reverse Engineering (Price Projection): The script takes these average Z-Score reversal levels and reverse-engineers the formula to find the corresponding price on the main chart: Projected Price = Mean + (Target Z * Standard Deviation)

- Noise Reduction: The raw Z-Score is smoothed using a Volume Weighted Moving Average (VWMA) to reduce false signals.


2. Key Features
Dynamic Predictive Zones (Main Chart):
- Red Zone (Resistance): Represents the price area where the Z-Score hits its historical average peak.
- Green Zone (Support): Represents the price area where the Z-Score hits its historical average trough.
Note: These zones expand and contract based on market volatility (Standard Deviation).


Dual Visualization:
- Bottom Pane: Shows the Z-Score oscillator with the calculated dynamic steps.
- Main Chart: Uses force_overlay=true to draw the corresponding price channels directly on the candles, allowing for real-time price action analysis.
- RSI Gradient Coloring: The oscillator line changes color based on RSI (Relative Strength Index) values to provide additional momentum context (Purple/Blue gradients).
- Signal Dots: Plots small circles on the main chart when the price enters these extreme statistical zones, indicating a potential mean reversion opportunity.


3. How to Use
This indicator is best used for Mean Reversion strategies.
- Potential Short: When price enters the Red Zone (Upper Channel) and a red dot appears, the price is statistically overextended relative to its recent volatility profile.
- Potential Long: When price enters the Green Zone (Lower Channel) and a green dot appears, the price is statistically undervalued relative to the mean.
- Trend Warning: If the price candles close forcefully beyond these zones and the zones begin to widen rapidly, it may indicate a breakout or a strong trend initiation rather than a reversal.


4. Settings
- Z-Score Length: The lookback period for the Mean and Standard Deviation.
- Lookback Depth: How many past reversal points the script should "remember" to calculate the average zones.
- Reversal Thresholds: The minimum Z-Score value required to register a peak or trough as a valid data point.
- Visuals: Toggle signal dots on/off.

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.