ta.percentrank
Rank the current value against its recent history on a 0 to 100 scale.
ta.percentrank(source, length, min=length)Percent rank in [0, 100]: 100 * (how many of the previous length observations are less than or equal to the current one) / length. The current bar is ranked against its history and is not counted in its own window. Ties count as "at or below", so a flat series ranks 100.
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. |
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
length + 1bars. Names in the warm-up are this operator’s parameters.- Missing values
- Returns na until length + 1 consecutive non-na observations have been seen (the current one plus the
lengthit is ranked against). An na resets the accumulation. With min=, an na is skipped and the rank is taken against the valid observations among thelengthbefore the bar, once there are at least min of them. A bar whose own value is na has no rank.
Example
ta.percentrank(close, 20)plot(ta.percentrank(close, 100), "Rank 100")