StatisticalPine Script v6

ta.percentile_nearest_rank()

Percentile (Nearest Rank)

Calculates the percentile using the nearest rank method.

Syntax

Syntax
ta.percentile_nearest_rank(source, length, percentage) → series float

Arguments

ParameterTypeDescription
sourceseries int/floatSeries of values to process.
lengthseries intNumber of bars in the rolling window.
percentagesimple int/floatTarget percentile in the 0-100 range.

Returns

P-th percentile of source for length bars back using nearest rank method.

Remarks

na values in the source series are ignored.

Code Examples

Pine Script v6 Example
//@version=6
indicator("percentile_nearest_rank")
plot(ta.percentile_nearest_rank(high, 50, 90), title="90th pct high")

Trading Applications

Calculate percentile levels using nearest rank method

Build percentile-based channel indicators

Identify extreme price levels statistically

Create robust outlier detection systems

Frequently Asked Questions

Generate ta.percentile_nearest_rank() Code with AI

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