Downloading...
OPEN-SOURCE SCRIPT

Stochastic Z-Score [AlgoAlpha]

2 914
🟠OVERVIEW
This indicator is a custom-built oscillator called the Stochastic Z-Score, which blends a volatility-normalized Z-Score with stochastic principles and smooths it using a Hull Moving Average (HMA). It transforms raw price deviations into a normalized momentum structure, then processes that through a stochastic function to better identify extreme moves. A secondary long-term momentum component is also included using an ALMA smoother. The result is a responsive oscillator that reacts to sharp imbalances while remaining stable in sideways conditions. Colored histograms, dynamic oscillator bands, and reversal labels help users visually assess shifts in momentum and identify potential turning points.

🟠CONCEPTS
The Z-Score is calculated by comparing price to its mean and dividing by its standard deviation—this normalizes movement and highlights how far current price has stretched from typical values. This Z-Score is then passed through a stochastic function, which further refines the signal into a bounded range for easier interpretation. To reduce noise, a Hull Moving Average is applied. A separate long-term trend filter based on the ALMA of the Z-Score helps determine broader context, filtering out short-term traps. Zones are mapped with thresholds at ±2 and ±2.5 to distinguish regular momentum from extreme exhaustion. The tool is built to adapt across timeframes and assets.

🟠FEATURES
  1. Z-Score histogram with gradient color to visualize deviation intensity (optional toggle).
    snapshot
  2. Primary oscillator line (smoothed stochastic Z-Score) with adaptive coloring based on momentum direction.
    snapshot
  3. Dynamic bands at ±2 and ±2.5 to represent regular vs extreme momentum zones.
    snapshot
  4. Long-term momentum line (ALMA) with contextual coloring to separate trend phases.
    snapshot
  5. Automatic reversal markers when short-term crosses occur at extremes with supporting long-term momentum.
    snapshot
  6. Built-in alerts for oscillator direction changes, zero-line crosses, overbought/oversold entries, and trend confirmation.


🟠USAGE
Use this script to track momentum shifts and identify potential reversal areas. When the oscillator is rising and crosses above the previous value—especially from deeply negative zones (below -2)—and the ALMA is also above zero, this suggests bullish reversal conditions. The opposite holds for bearish setups. Reversal labels ("▲" and "▼") appear only when both short- and long-term conditions align. The ±2 and ±2.5 thresholds act as momentum warning zones; values inside are typical trends, while those beyond suggest exhaustion or extremes. Adjust the length input to match the asset’s volatility. Enable the histogram to explore underlying raw Z-Score movements. Alerts can be configured to notify key changes in momentum or zone entries.

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.