Z-Score

How many standard deviations a value sits from the mean of its last n values. How AlgoLift computes the Z-Score and how to read it.

IndicatorBy AlgoLiftUpdated 3 min read
On this page 12What it measuresFormulaInputs in AlgoLiftRecommended periodsOutputs in AlgoLiftHow to read itBest in, worst inThree setups1. Fade the stretch2. Stretch with a trend filter3. Breakout strengthCommon mistakes

TL;DR. (value − mean of the last n values) / their standard deviation. 0 is the window's average; 2 means two standard deviations above it, an unusual stretch for this window; −2 the mirror. One scale for every instrument and price level.

What it measures

  • Stretch from a recent average. How far the value has moved from its own mean, in units of its own recent variability.
  • A unit-free reading. Dividing by the standard deviation removes the price scale, so a Z-Score of 2 means the same thing on a stock at 20 and an index at 5,000.
  • The idea behind the Bollinger Bands. Price at the upper Bollinger Bands band is a Z-Score of about 2 at the same period. The Z-Score node gives you the number itself.

Formula

Inputs in AlgoLift

SettingDefaultRangeNotes
Period302 to 500Bars the mean and deviation are taken over.
SourceCloseClose, Open, High, Low, HL2, HLC3, OHLC4Which value of each bar is scored.
  • 10 to 20 (fast): Short stretches inside a session.
  • 30 (default): A balanced window.
  • 100 to 200 (slow): How unusual today is against a longer regime.

Outputs in AlgoLift

HandleTypePlottedNotes
Z-ScoreNumericAlwaysStandard deviations from the window mean, drawn in its own panel around 0 with guides at 2 and −2.

How to read it

  • Above 2: the value is unusually high for this window. A mean-reversion rule reads it as stretched; a momentum rule as strong.
  • Below −2: the mirror, unusually low.
  • Crossing back inside ±2: the stretch is easing, the moment many fade rules enter.
  • Persistently on one side of 0: a trend. The mean is chasing the value and the score stays positive (or negative) for a long time.
Common Misconception
Myth
A Z-Score of 2 means a 2.5% chance, so price must come back.
Reality
That reading assumes returns are normally distributed and independent. Prices trend and have fat tails, so scores of 3 and 4 happen far more often than a bell curve says, and a trend can hold a score above 2 for many bars.

Best in, worst in

Best in ranging markets and mean-reversion rules, where an extreme score tends to unwind toward the average.

Worst in strong trends: the score stays high, and a rule that fades every reading above 2 keeps selling into strength.

Three setups

1. Fade the stretch

Enter short when the Z-Score crosses below 2 from above (a Crossover node reading the line and a constant), long when it crosses above −2 from below. Exit at 0, through a Comparison wired into Set Exit Condition.

2. Stretch with a trend filter

Only fade toward the trend: buy a Z-Score below −2 only while price is above its 200-bar average. The filter keeps the rule out of the falls that keep falling.

3. Breakout strength

Read a Z-Score above 2 as strength instead: enter long when it crosses above 2 and the session is trending, with the stop placed through a Bracket Order.

Common mistakes

  • Treating ±2 as a probability. It is a distance in the window's own deviation, not a percentage chance.
  • Fading in a trend. An extreme score in a trend is the trend. Add a filter or a confirmation.
  • Tuning the period and threshold together to the decimal. A rule that works at period 27 and 2.1 and fails nearby has found noise (overfitting in trading).
Key Takeaway

The Z-Score puts any series on one scale: distance from its recent mean in its recent standard deviations. Extremes say "unusual for this window", not "about to reverse".