ta.percentrank()Percent Rank
ta.percentrank() returns the percentage of values in the lookback window that are less than or equal to the current source value, producing a comparable 0–100 rank.
Pine Script v6 reference verified: · TradingView reference
Syntax
ta.percentrank(source, length) → series floatArguments
| Parameter | Type | Description |
|---|---|---|
| source | series int/float | Series of values to process. |
| length | series int | Number of bars in the rolling window. |
Returns
A series float representing the current source value’s percent rank over the requested lookback window.
Remarks
na values in the source series are included in the calculation and produce an na result.
Code Examples
//@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
Related Functions
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.
Related Pine Script Functions
ta.percentile_linear_interpolation()
Learn how to use ta.percentile_linear_interpolation() in Pine Script. Calculate percentiles using linear interpolation.
ta.percentile_nearest_rank()
Learn how to use ta.percentile_nearest_rank() in Pine Script. Calculate percentiles using nearest rank method.
ta.median() - Median
Learn how to use ta.median() in Pine Script. Calculate the median value for robust price analysis.
ta.stdev() - Standard Deviation
Learn how to use ta.stdev() in Pine Script. Syntax, parameters, code examples for statistical standard deviation calculation.
ta.rsi() - Relative Strength Index
Learn how to use ta.rsi() in Pine Script. Syntax, parameters, code examples for the RSI momentum oscillator.