Median
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
| 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
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.