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
| Setting | Default | Range | Notes |
|---|---|---|---|
| Period | 30 | 2 to 500 | Bars the mean and deviation are taken over. |
| Source | Close | Close, Open, High, Low, HL2, HLC3, OHLC4 | Which value of each bar is scored. |
Recommended periods
- 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
| Handle | Type | Plotted | Notes |
|---|---|---|---|
| Z-Score | Numeric | Always | Standard 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.
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).
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".