Z-Score Node
Standardized deviation from mean - fundamental normalization metric
Overview
Z-Score is the standardized distance from the mean in units of standard deviation. Z = (Value - Mean) / StdDev. A Z-score of 0 means at the mean; +2 means 2 standard deviations above mean; -3 means 3 below. Z-scores convert any distribution into standard normal for comparison across assets and timeframes.
Z-Score is the foundation of mean reversion trading: extreme Z-scores (|Z| > 2) signal mean reversion opportunities. Use with HalfLifeMeanReversion to quantify how fast reversion occurs. For machine learning, Z-Score normalization standardizes features for better model training.
Formula & Calculation
μ = rolling mean
σ = rolling standard deviation
Z = ±1: 68% of data within range
Z = ±2: 95% of data within range (extreme zone)
Z = ±3: 99.7% of data (very extreme)
Parameters
| Parameter | Default | Description |
|---|---|---|
| lookback | 20-252 | Historical window for mean/std |
| entry_threshold | ±2.0 | Entry signal trigger |
Common Use Cases
1. Mean Reversion Entry
Buy when Z < -2 (oversold), sell when Z > +2 (overbought). Pair with HalfLifeMeanReversion to confirm reversion speed. Example: SPY drops and Z = -2.5, quick HalfLife (<5 bars) = strong entry.
2. Outlier Detection
|Z| > 3 signals statistical anomaly requiring investigation. Data quality check: extreme Z-scores may indicate data errors or true rare events. Use for alert generation.
3. Feature Normalization
Normalize inputs for ML models: Z-score brings all features to ~(-3, +3) range. Improves neural network convergence and coefficient interpretation. Standard preprocessing step.
4. Cross-Asset Comparison
Compare BTC at Z=2.5 vs SPY at Z=1.8: both extreme but BTC more extreme. Z-scores enable apples-to-apples comparison despite different scales and volatilities.
Advantages & Limitations
Advantages
- Universal normalization
- Easy interpretation
- Works across assets
- Foundation for statistics
Limitations
- Assumes normality
- Lagging indicator
- Backward-looking
- Fails in regime shifts