Returns the value a given percentage of the way up the sorted last length bars, blending the two nearest ranks.
ta.percentile_linear_interpolation sorts the window and finds position percentage / 100 * (length - 1) along it. When that falls between two values, the result blends them in proportion, so it can be a number that is not in the window.
Percentile 0 gives the smallest value, 100 the largest, and 50 matches ta.median. Early bars return na until the window is full.
Syntax
ta.percentile_linear_interpolation(source: series int/float, length: series int, percentage: simple int/float) -> series floatArguments
| Name | Type | Default | Description |
|---|---|---|---|
| source | series int/ | required | The series whose last length values are ranked; the result can fall between two of them. |
| length | series int | required | Number of bars in the window. A whole number of 1 or more. |
| percentage | simple int/ | required | Percentile to find, from 0 to 100. |
Returns
series float: the interpolated percentile value, or na while the window is not full.
Remarks
- Prefer it to the nearest-rank form when the window is short and steps would be coarse.
Example
//@version=6
indicator("Interquartile band", overlay = true)
q1 = ta.percentile_linear_interpolation(close, 40, 25)
q3 = ta.percentile_linear_interpolation(close, 40, 75)
p1 = plot(q1, "Q1", color = color.gray)
p2 = plot(q3, "Q3", color = color.gray)
fill(p1, p2, color = color.new(color.gray, 85))See also
Runs on Sidechair