Standardize¶
Math · Normalize
Rolling z-score: (value − rolling mean) ÷ rolling stddev. Output expresses each bar as 'how many standard deviations from the local mean it sits' — comparable across instruments and indicators. Constant windows (zero stddev) emit NaN.
Standardize converts a series into a rolling z-score: how many standard deviations each bar sits from its recent mean. A reading of 0 means "right at the local average," +2 means "two standard deviations above — unusually high," −2 means "unusually low." It's the statistician's way of saying "how extreme is this, really?", and because it's expressed in standard deviations it's directly comparable across instruments and indicators.
How it works¶
Each bar the block computes (value − rolling mean) / rolling stddev over the Window (bars) (default 20). The output is unbounded but typically lives in roughly −3…+3, since values rarely stray beyond three standard deviations. A flat window (zero standard deviation) emits NaN. Feed it Bars (uses close) or any series. It's essentially the Z-Score indicator exposed as a general-purpose math transform.
When to use it¶
Use Standardize to measure statistical extremity and to combine indicators fairly. A z-score of price says how stretched it is from its mean — high absolute values flag mean-reversion opportunities (fade the extreme) or breakouts (a genuine regime shift). Because z-scores share a scale, standardizing several indicators lets you blend them without one dominating. Compared with Min-Max Normalize: standardize reflects the distribution's spread (so it's robust to a single far-out extreme), while min-max pins to the window's literal high/low.
Example¶
A mean-reversion fade: Standardize price over 20 bars, then take the absolute value and a Greater Than against 2 to flag "more than 2σ from the local mean in either direction." Fade those extremes back toward the mean, gated to a non-trending regime, and backtest in the Tester.
Tips & gotchas¶
- Units are standard deviations — ±2 is notable, ±3 rare; directly comparable across markets.
- Combine indicators fairly — z-scoring each puts them on equal footing.
- Versus Min-Max Normalize — z-score is spread-aware (robust to a lone outlier); min-max is range-bounded.
- Flat window → NaN (zero stddev). It's the general-purpose form of the Z-Score indicator.
Related blocks¶
Inputs¶
| Socket | Type | What to wire in |
|---|---|---|
| In | series / bars |
Source series. BARS input uses close. |
Outputs¶
| Output | Type | Plots as | Description |
|---|---|---|---|
| z | series |
Line · sub-pane | Per-bar rolling z-score. |
Parameters¶
| Parameter | Type | Default | What it does |
|---|---|---|---|
| Window (bars) | number · 2–500 | 20 |
Rolling window for the mean / stddev. |
Reference auto-generated from the block catalog · category Math.