ta.percentile
Read a percentile of the window, such as the 90th percentile of recent closes.
ta.percentile(source, length, percentage, min=length)Window percentile, the one name to reach for: it is exactly ta.percentile_linear_interpolation, position percentage/100 * (length - 1) counted from 0, interpolated between the two ranks it falls between, which equals ta.median at 50. The nearest-rank variant, which always returns an observation that occurred, stays available as ta.percentile_nearest_rank.
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.
| Name | Kind | Type | Default | Range | Description |
|---|---|---|---|---|---|
source | Series | number | - | - | The series to read. |
length | Constant | number | - | 1 to 10000 | Window in observed bars. |
percentage | Constant | number | 50 | 0 to 100 | Which percentile to take, 0 to 100. 50 is the median. |
min | Constant | number | - | 1 to 10000 | Valid 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
| Name | Type |
|---|---|
value | number |
Warm-up and missing values
- Warm-up
lengthbars. Names in the warm-up are this operator’s parameters.- Missing values
- Returns na until
lengthconsecutive 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
ta.percentile(close, 20, 50)plot(ta.percentile(close, 100, 90), "Ninetieth 100")