Concept

Z-score

Z-score, also known as rolling z-score, is a Statistics concept. The Library holds 7 implementations, each one a working definition you can pull into Quant.

Top Z-score indicators

7 total

What is a Z-score?

A z-score expresses how far the current value of a series sits from its recent average, measured in standard deviations. A rolling implementation takes the last N values of any input (price, returns, volume, an oscillator, a spread), computes their mean and standard deviation, then divides the current value's deviation from that mean by the standard deviation. A reading of 0 sits exactly at the mean, +2 is two standard deviations above it, and negative readings mirror below.

The transform matters because it puts unrelated series on one unitless scale, which is the foundation of much mean-reversion and normalization logic: Bollinger Bands are simply the price levels where the z-score equals a chosen multiplier. The usual caution applies. The textbook intuition that roughly 95% of values stay inside ±2 assumes a normal distribution, and market returns are fat-tailed with a drifting mean, so extreme z-scores occur more often than the table suggests and can stay extreme while a trend runs.

How to calculate a Z-score

The rolling calculation needs only a window, a mean, and a standard deviation.

  1. 1Choose the input series and a lookback window N. Returns and oscillator values are better behaved than raw price, which trends and drags the mean along behind it.
  2. 2Compute the mean and the standard deviation of the last N values.
  3. 3Subtract the mean from the current value and divide the result by the standard deviation. The output is the distance from the window average, expressed in standard deviations.
  4. 4Plot it as an oscillator around zero, typically with reference lines at ±1, ±2, and ±3 marking increasingly rare readings.

How traders use it

  • As a mean-reversion trigger: readings beyond a threshold such as ±2 flag statistically stretched values, with entries taken back toward the mean. Thresholds are conventions rather than guarantees, and trending markets can hold a z-score pinned high or low for long stretches, which is why many systems pair the trigger with a trend filter.
  • As a common scale for comparison: z-scoring lets momentum, stretch, or relative volume be ranked across different symbols and timeframes on equal footing, since every input becomes 'standard deviations from its own norm'.
  • As the engine of spread trading: pairs models z-score the spread between two related instruments and trade its extremes, usually after a cointegration check confirms the spread actually reverts.
  • As an outlier flag: a z-scored volume series is one standard way to define a volume spike, and the same treatment isolates unusually wide ranges or gaps.

Z-score vs related concepts

Percentile Rank: Percentile rank counts how many past values sit at or below the current one, using order alone. A z-score measures distance in standard deviations, so it preserves magnitudes but leans on the distribution being roughly normal; percentile rank makes no such assumption and saturates at the window's extremes.

Min-max Scaling: Min-max scaling positions the value between the window's minimum and maximum, so a single outlier stretches the scale and compresses everything else. A z-score is anchored to the mean and standard deviation, which dampens, though does not remove, the influence of one extreme print.

Bollinger Bands: The two are the same mathematics displayed differently: the bands draw the mean plus and minus k standard deviations on the price panel, while the z-score plots the equivalent position as an oscillator. A close on the upper band and a z-score of +k (same window and source) are identical statements.

More Z-score implementations

Related concepts · Normalization & distribution

Concept family

Statistics

45 concepts mapped · 37 in the Library

Z-score FAQ

What is a good z-score threshold for trading signals?

Common conventions are ±2 for stretched and ±3 for extreme, echoing normal-distribution benchmarks. Because returns are fat-tailed and regimes shift, the frequency of those readings varies widely across markets and window lengths. Treat thresholds as parameters to test rather than fixed rules, and expect more ±3 events than a normal table implies.

What lookback period should a rolling z-score use?

There is no universal setting. Short windows adapt quickly but produce noisy standard-deviation estimates; long windows are stable but slow to accept a regime change. A practical approach is to match the window to the horizon of the reversion you trade, then confirm the signal is not hypersensitive to small changes in that length.

Does a z-score above 2 mean price will revert?

No. It says the current value is unusual relative to the recent window, not that a reversal is due. In a strong trend the rolling mean chases price, so the score can stay elevated bar after bar. Most systems require additional confirmation, such as a momentum stall or a level, before fading a stretched reading.

Build Z-score your way.

Quant writes, tests, and refines it with you — then it runs on LuxAlgo charting or ports to TradingView.