Z-Score¶
Indicators · Statistical
Standardized deviation of source from its rolling mean.
Z-Score measures how far price (or any series) has strayed from its recent average, in standard deviations. A z-score of 0 means "right at the mean," +2 means "two standard deviations above — statistically stretched," −2 means "stretched below." It's the cleanest, most rigorous way to quantify "how extreme is this right now," and because it's expressed in standard deviations it reads the same on any instrument — a +2 on EURUSD means the same kind of stretch as a +2 on BTCUSD.
How it works¶
Over the Period (default 20) the block computes the rolling mean and standard deviation of the Source, then outputs (value − mean) / stddev — the z-score — in a sub-pane. A Threshold (default 2.0) defines the extremes, with z > + and z < − signals firing when the score pushes beyond ±threshold. Readings typically live within ±3 since values rarely stray further. It's the indicator-form sibling of the Standardize math block.
When to use it¶
Use Z-Score for mean-reversion and statistical-extreme strategies. The classic play: fade extreme readings — when price hits +2 (overextended above its mean) look for shorts back toward the mean, and −2 for longs. It's also a clean overbought/oversold gauge that adapts to the instrument's own volatility (unlike a fixed-level oscillator). And because z-scores are comparable, it's ideal for pairs and statistical-arbitrage constructions (the z-score of a spread). As always, an extreme in a strong trend can keep getting more extreme — pair with a regime filter before fading.
Example¶
A statistical mean-reversion fade: wire bars into Z-Score (20, threshold 2), take the z < − signal (price stretched 2σ below its mean) with the score turning back up via a Crosses Above, and route to a Buy Signal targeting the mean — gated to a non-trending regime by ADX / DMI. Backtest in the Tester.
Tips & gotchas¶
- Units are standard deviations — ±2 notable, ±3 rare; comparable across instruments.
- Adapts to the instrument's own volatility — better than a fixed-level oscillator.
- Ideal for spread/pairs z-scores — the basis of statistical arbitrage.
- Don't fade a trend blindly — an extreme can stretch further; filter the regime. It's the indicator form of Standardize.
Related blocks¶
Inputs¶
| Socket | Type | What to wire in |
|---|---|---|
| Source | bars / series |
Price bars or any indicator series |
Outputs¶
| Output | Type | Plots as | Description |
|---|---|---|---|
| Z | series |
Line · sub-pane | Z-score |
| z > + | signal |
— | z > +threshold |
| z < − | signal |
— | z < −threshold |
Parameters¶
| Parameter | Type | Default | What it does |
|---|---|---|---|
| Period | number · 2–500 | 20 |
|
| Threshold | number · 0.0–10.0 | 2.0 |
|
| Source | choice (close, open, high, low, hl2, hlc3, ohlc4) |
close |
|
| Line color | colour | #ce93d8 |
Reference auto-generated from the block catalog · category Indicators.