Q1 (First Quartile)
The Q1 node returns the 25th percentile of the rolling window using linear interpolation between adjacent sorted values. 25% of all non-null values in the window fall below Q1. Combined with Q3 and IQR, Q1 defines the lower bound of the central distribution — useful for detecting conditions where the current value has fallen to historically cheap levels within the lookback.
Algorithm
- ▸Sort non-null window values ascending
- ▸p = 25; idx = (p/100) × (n−1)
- ▸lo = floor(idx), hi = ceil(idx)
- ▸output = sorted[lo] + (sorted[hi] − sorted[lo]) × (idx − lo)
- ▸Returns null if no non-null values
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| period | number | 20 | Rolling window size. |
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
Oversold Level
When an oscillator (RSI, Williams %R) falls to or below its own rolling Q1, it has reached the lower quartile of its recent range — a quantile-based oversold condition.
Lower Fence Construction
Q1 − 1.5 × IQR defines the lower whisker of a box plot — values below this are statistical outliers and may signal abnormal conditions.
Adaptive Band
Use Q1 as the lower band of a quantile channel around price, giving a distribution-aware support level that adapts to the actual price distribution rather than assuming normality.