Returns the percentage of the previous length values of source that are less than or equal to the current value.
ta.percentrank looks back over the length bars before the current bar and counts how many of them are at or below the current value. The count is divided by length and scaled to 100.
A reading of 100 means the current value is at least as high as every bar in the window. It needs length earlier bars plus the current one, so output begins on bar number length + 1.
Syntax
ta.percentrank(source: series int/float, length: series int) -> series floatArguments
| Name | Type | Default | Description |
|---|---|---|---|
| source | series int/ | required | The series whose current value is ranked against its last length values. |
| length | series int | required | Number of earlier bars compared against. A whole number of 1 or more. |
Returns
series float: a value from 0 to 100, or na while there are fewer than length earlier bars.
Remarks
- The current bar is not part of the window it is compared with.
Example
//@version=6
indicator("Volume percent rank")
plot(ta.percentrank(volume, 100), "Rank", color = color.blue, style = plot.style_histogram)
hline(90)
hline(10)See also
Runs on Sidechair