Z Score (simple)
systemic:core-zscrsimpleStatisticsInputs
| Name | Type | Description |
|---|---|---|
| Data | Number series | The series of values to score, for example closing prices or volume. |
Outputs
| Name | Type | Description |
|---|---|---|
| Z Score | Number series | The number of standard deviations the Data value is above or below the mean, at each bar. |
Cost
0.198 + 0.00574·n credits for n bars, rounded up. The marks are each plan's limit of bars.
The Z-Score measures how many standard deviations a value is from the mean. In trading, it shows how "unusual" the current price is compared with its history, which is the basis of mean-reversion strategies.
Where:
- = Current value
- = Mean
- = Standard deviation
Z Score (custom) takes and from its Average and Standard Deviation inputs, bar by bar. Z Score (simple) takes only the data. It uses the mean and standard deviation of all bars from the start of the run up to the current bar.
How It Works
flowchart TD
subgraph Input["Price Data"]
P["Data series"]
end
subgraph Stats["Statistical Calculation"]
MEAN["μ = Mean of prices"]
STD["σ = Standard deviation"]
CURR["X = Current price"]
end
subgraph Calc["Z-Score"]
DIFF["X - μ"]
DIV["÷ σ"]
Z["Z-Score"]
end
P --> MEAN & STD
CURR & MEAN --> DIFF
DIFF & STD --> DIV --> Z
Missing Data
If any value the calculation needs at a bar is empty (a data gap or a closed-market day), the Z-Score at that bar is empty. Gaps are never filled: a gap in your inputs stays a gap in the output.
The Z-Score is also undefined when the standard deviation is zero, because a flat series has no "distance from the mean". That bar is empty too, not 0. In Z Score (simple), this always applies to the first bar that has a value.
| X | μ | σ | Z-Score |
|---|---|---|---|
| empty | 100 | 5 | empty |
| 110 | empty | 5 | empty |
| 110 | 100 | 0 | empty |
| 110 | 100 | 5 | 2.0 |
Interpreting Z-Score
| Z-Score | Interpretation |
|---|---|
| > +2 | Far above average (possibly overbought) |
| +1 to +2 | Above average |
| -1 to +1 | Normal range |
| -2 to -1 | Below average |
| < -2 | Far below average (possibly oversold) |
flowchart LR
subgraph Zones["Z-Score Distribution"]
EXT2[">+2 σ<br/>Extreme high"]
HIGH["+1 to +2 σ<br/>Above normal"]
NORM["-1 to +1 σ<br/>Normal (68%)"]
LOW["-2 to -1 σ<br/>Below normal"]
EXT1["<-2 σ<br/>Extreme low"]
end
EXT2 --> HIGH --> NORM --> LOW --> EXT1
Trading Applications
1. Mean Reversion Strategy
| Z-Score | Signal |
|---|---|
| < -2 | Consider buying (price abnormally low) |
| > +2 | Consider selling (price abnormally high) |
| Approaching 0 | Take profits (returning to mean) |
2. Pairs Trading
Compare Z-Scores of two correlated assets:
- Diverging Z-Scores → Trade the spread
- Converging Z-Scores → Close position
3. Risk Management
Flag positions where the Z-Score exceeds a threshold, for review.
Statistical Context
The Z-Score assumes a normal distribution:
| Z-Score Range | Data Within Range |
|---|---|
| ±1σ | ~68% |
| ±2σ | ~95% |
| ±3σ | ~99.7% |
In practice, financial data often has "fat tails": extreme events happen more often than a normal distribution predicts.
Parameters
| Module | Look-back for mean and standard deviation |
|---|---|
| Z Score (custom) | The window of the modules you connect to Average and Standard Deviation (common: 20, 50, 100 bars) |
| Z Score (simple) | All bars from the start of the run to the current bar |
Shorter look-backs = more reactive but noisier
Longer look-backs = smoother but slower to adapt
Z-Score vs Other Normalization
| Method | Formula | Use Case |
|---|---|---|
| Z-Score | (X - μ) / σ | Mean reversion, outlier detection |
| Min-Max | (X - min) / (max - min) | Bounded 0-1 scaling |
| Percentile | Rank / N | Distribution-free ranking |
Advantages
- Standardized — Comparable across assets
- Statistical foundation — Based on probability theory
- Mean reversion — Well suited to reversion strategies
- Outlier detection — Identifies unusual price behavior
Disadvantages
- Assumes normality — Markets often have fat tails
- Backward-looking — Mean and standard deviation come from history
- Look-back sensitive — The look-back length matters
- Trending markets — May give signals too early