DocsMathStatisticsQ1 (First Quartile)

Q1 (First Quartile)

Windowed · default period 20Statistics

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

NameTypeDefaultDescription
periodnumber20Rolling window size.

Inputs & Outputs

PortTypeDescription
Inputs
inputnumber[]Source numeric array
Outputs
valuesnumber | nullComputed value at each bar; null before the warmup period completes
timestampsnumber[]Bar timestamps (UNIX ms), aligned 1-to-1 with values
Live mode: In live streaming mode the node updates only the last bar in-place rather than recalculating the full array, keeping CPU usage minimal during real-time data feeds.

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.