Sidechair

ta.rci()

Browse the reference

Returns the rank correlation index: how closely the price ranking in the window follows time order, from -100 to 100.

Try it in the editor

ta.rci ranks the values in the window from lowest to highest, with ties sharing the average of their ranks, and correlates that ranking with the order of the bars. The result is scaled to percent.

+100 means every bar was higher than the one before it; -100 means every bar was lower. Output starts once length bars are available, and an na in the window gives na.

Syntax

Pine Script
ta.rci(source: series int/float, length: simple int) -> series float

Arguments

NameTypeDefaultDescription
sourceseries int/floatrequiredThe series whose rank order is compared with time order over the last length bars.
lengthsimple intrequiredNumber of bars ranked. A whole number of 2 or more.

Returns

series float: a value from -100 to 100, or na while the window is not full.

Remarks

  • Rank-based, so a single extreme value moves it no more than any other bar.

Example

Pine ScriptRank correlation of the closeOpen in editor
//@version=6
indicator("RCI")
plot(ta.rci(close, 9), "RCI", color = color.teal)
hline(80)
hline(-80)

See also

Runs on Sidechair