Stochastic Z-Score Momentum Oscillator Guide

Normalizes price deviations and smooths them into a momentum oscillator with a separate longer-term context line.

Free, open-source Pine Script by AlgoAlpha. TradingView account and plan limits apply.

TradingView chart preview of Stochastic Z-Score by AlgoAlpha.
Published AlgoAlpha chart preview. The layout depends on your chart and inputs.

Inputs to start with

Source
Controls the base price used by the calculation. Leave the same price source selected when comparing oscillator length.
Length ยท 21 by default
Changes the normalization lookback. Longer windows usually smooth the baseline, which also changes what qualifies as an unusual price move.
Show Histogram
Displays the raw Z-score as columns. Use it alongside the smoothed oscillator and the longer-term line when you want to compare an impulse with its context.

Try it on a chart

Find an unusually large oscillator excursion in both a trend and a sideways market. Note when the fast line leaves the outer zone and whether the longer-term context changes at the same time. A stretched reading can persist, so log a sequence of bars instead of using the first extreme as a reversal trigger.

What to check. An extreme can persist. Check how thresholds behave over both trending and sideways periods with the same settings.