Skip to content
Algo Trade Analytics Docs

ta.rsi() - Pine Script Function

Relative strength index. It is calculated using the ta.rma() of upward and downward changes of source over the last length bars.

ta.rsi(source, length) → series float
NameTypeDescription
sourceseries int/floatSeries of values to process.

Relative strength index.

  • na values in the source series are ignored; the function calculates on the length quantity of non-na values.
//@version=6
indicator("ta.rsi")
plot(ta.rsi(close, 7))// same on pine, but less efficientpine_rsi(x, y) => u = math.max(x - x[1], 0) // upward ta.change d = math.max(x[1] - x, 0) // downward ta.change rs = ta.rma(u, y) / ta.rma(d, y)
res = 100 - 100 / (1 + rs)
res
plot(pine_rsi(close, 7))