StatisticalPine Script v6

ta.percentile_linear_interpolation()Percentile (Linear Interpolation)

Calculates the percentile using linear interpolation between the two nearest ranks.

Syntax

Syntax
ta.percentile_linear_interpolation(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 linear interpolation.

Remarks

na values in the source series are ignored.

Code Examples

Pine Script v6 Example
//@version=6
indicator("percentile_linear_interpolation")
p50 = ta.percentile_linear_interpolation(close, 100, 50)
plot(p50, title="Median-like (50th pct)")

Trading Applications

Calculate precise percentile levels for price analysis

Build adaptive bands based on percentile levels

Create dynamic support/resistance from statistical distributions

Use for non-parametric volatility measurement

Frequently Asked Questions

It returns the value at the requested percentile over the rolling window, estimating between sorted neighbors with linear interpolation for smoother levels than discrete ranks alone.

Linear interpolation blends between the two closest order statistics; nearest rank picks an actual observed value from the window. Interpolated percentiles can lie between ticks.

Common uses include channel midlines (50th), risk tails (5th/95th), and adaptive bands where band width reflects the empirical distribution of recent prices.

Generate ta.percentile_linear_interpolation() Code with AI

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