Docs

ta.median

Smooth a series with the middle value of the window, which ignores outliers.

itm
ta.median(source, length, min=length)

Median of the window: the middle value of the sorted observations when length is odd, and the mean of the two middle values when it is even, rather than the lower of them.

Parameters

A series parameter takes a value on every bar. A constant parameter must be known before the first bar, such as a number or an input.

NameKindTypeDefaultRangeDescription
sourceSeriesnumber--The series to read.
lengthConstantnumber-1 to 10000Window in observed bars.
minConstantnumber-1 to 10000Valid values the window must hold before it reports (an option, written min=15). An na is skipped. Absent = length: the window must be full and gap-free.

Output

NameType
valuenumber

Warm-up and missing values

Warm-up
length bars. Names in the warm-up are this operator’s parameters.
Missing values
Returns na until length consecutive non-na observations are in the window. An na resets the accumulation. With min=, an na is skipped and the value is taken over the valid observations once there are at least min of them.

Example

itm
ta.median(close, 20)
itm
plot(ta.median(close, 20), "Median 20")