Z-Score Robust Node
Robust Z-Score — Median & MAD
Overview
The Z-Score Robust Node computes a rolling robust Z-score using the median and median absolute deviation (MAD) instead of mean and standard deviation. This makes it highly resistant to outliers and extreme price spikes.
In financial data, flash crashes, earnings gaps, and data errors can distort mean-based Z-scores significantly. Robust Z-score keeps its scaling stable even when outliers are present in the window, producing more reliable normalisation for noisy series.
Formula
Parameters
| Parameter | Default | Description |
|---|---|---|
| period | 20 | Rolling window in bars |
Inputs & Outputs
| Slot | Direction | Type | Description |
|---|---|---|---|
| input | Input | { values, timestamps } | Any numeric series |
| values | Output | (number | null)[] | Robust Z-score per bar; null during warm-up; 0 when MAD = 0 |
| timestamps | Output | number[] | Unix timestamps aligned to input |
Use Cases
Noisy / Illiquid Markets
Ideal for thinly-traded assets where price spikes distort mean-based statistics. Robust Z-score remains stable even when one or a few bars are extreme outliers.
Earnings / Event Filtering
After an earnings spike, standard Z-score shifts dramatically. Robust Z-score absorbs the spike into the median without destabilising the entire window's scaling.
Alternative Data Normalisation
Normalise alternative data feeds (sentiment, volume anomalies) that are inherently skewed or spikey — where MAD-based scaling outperforms standard deviation.
Tips & Best Practices
Robust vs Standard Z-Score
Use standard Z-Score Pass when your data is clean and roughly normal. Use Robust Z-Score when you expect fat tails, outliers, or data quality issues in the window.
MAD = 0 Returns 0
When all values in the window are identical (MAD = 0), the node returns 0 rather than null. This avoids null propagation, but monitor for this condition in synthetic or constant-price data.
Scaling Difference
Robust Z-score does not scale to unit variance. For Gaussian data, MAD ≈ 0.80 × σ, so robust Z-scores are slightly larger in magnitude than standard Z-scores for the same data.