ta.rank
Rank the current value among the last n values, with 1 as the lowest.
ta.rank(source, length, min=length)Rank of the current observation among the last length observations including itself, counted ascending from 1: 1 is the lowest in the window and length the highest. Ties count as at-or-below, so a flat window ranks length. This is not ta.percentrank, which excludes the current bar from its own window and divides by length to give a percentage.
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
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 rank is taken among the valid observations once there are at least min of them. A bar whose own value is na has no rank.
Example
ta.rank(close, 20)plot(ta.rank(close, 20), "Rank 20")