median

Statistical Median

median(source, period)

Parameters

Name Type Description
source field Data series to calculate median of
period int Number of periods for median calculation

Formula

Median = Middle value when data is sorted

Examples

// price above 20-period median
x = median(close, 20); close > x;
// volume above median (outlier-resistant)
volume > median(volume, 50);
// median price rising
median(close, 20) > median(close, 20)[5];

Returns

float

Range

period must be 2-400

Notes

Less sensitive to outliers than mean/SMA and computationally more expensive; uses PERCENTILE_CONT(0.5) for calculation