Median

Windowed · default period 20Statistics

The Median node returns the middle value of the sorted window (average of two middle values for even-sized windows). The median is a robust measure of central tendency completely unaffected by extreme outliers — making it superior to the mean for noisy price series, volume spikes, and non-normally distributed returns. It is the center of box-plot-style range analysis.

Algorithm

  • Sort non-null window values ascending
  • For odd n: output = sorted[floor(n/2)]
  • For even n: output = (sorted[n/2−1] + sorted[n/2]) / 2
  • 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

Outlier-Resistant Moving Average

Use Median instead of Average for a "moving median" that ignores spikes — useful on volume or bid-ask spread series that have frequent anomalous values.

Robust Signal Baseline

Subtract a rolling Median from an indicator to center it without being pulled by outliers — produces a more stable oscillator than mean-subtraction.

Box Plot Visualization

Combine Median, Q1, Q3, Min, and Max nodes to build a rolling box plot visualization showing the full distribution of a series over time.