StatisticalPine Script v6

ta.percentrank()

Percent Rank

Percent rank is the percentage of how many previous values were less than or equal to the current value of a given series.

Syntax

Syntax
ta.percentrank(source, length) → series float

Arguments

ParameterTypeDescription
sourceseries int/floatSeries of values to process.
lengthseries intNumber of bars in the rolling window.

Returns

Percent rank of source for length bars back.

Remarks

na values in the source series are ignored.

Code Examples

Pine Script v6 Example
//@version=6
indicator("ta.percentrank")
plot(ta.percentrank(close, 50))

Trading Applications

Rank current value relative to historical values

Identify extreme readings for mean reversion

Build percentile-based trading signals

Normalize indicators across different securities

Frequently Asked Questions

Generate ta.percentrank() Code with AI

Skip the manual coding. Use Pineify's AI Coding Agent to generate Pine Script code using ta.percentrank() and other built-in functions instantly.