IQR (Interquartile Range)
The Interquartile Range node computes Q3 − Q1 using linear interpolation within the rolling window. IQR is a robust spread measure that ignores the top and bottom 25% of values — making it insensitive to extreme outliers. It is the preferred spread measure when the distribution contains fat tails or outliers, which is common in financial data. Requires at least 4 non-null values.
Algorithm
- ▸Sort non-null window values ascending
- ▸Q1 = linear interpolation at the 25th percentile
- ▸Q3 = linear interpolation at the 75th percentile
- ▸IQR = Q3 − Q1
- ▸Requires ≥ 4 non-null values; returns null otherwise
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| period | number | 20 | Rolling window size. Minimum 4. |
Inputs & Outputs
| Port | Type | Description |
|---|---|---|
| Inputs | ||
| input | number[] | Source numeric array |
| Outputs | ||
| values | number | null | Computed value at each bar; null before the warmup period completes |
| timestamps | number[] | Bar timestamps (UNIX ms), aligned 1-to-1 with values |
Use Cases
Outlier-Robust Volatility
Use IQR × 1.35 as a robust estimator of the standard deviation for fat-tailed return distributions where Stddev is inflated by occasional large moves.
Price Range Quality
Compare IQR of close prices to the full Range (Max − Min) to measure how much of the total price movement is in the central distribution vs. outlier spikes.
Regime Detection
Narrowing IQR indicates price compression; widening IQR indicates expanding volatility. Use as a Bollinger Band equivalent with outlier resilience.