ta.rsi() - Pine Script Function
ta.rsi()
Section titled “ta.rsi()”Overview
Section titled “Overview”Relative strength index. It is calculated using the ta.rma() of upward and downward changes of source over the last length bars.
Syntax
Section titled “Syntax”ta.rsi(source, length) → series floatParameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
| source | series int/float | Series of values to process. |
Returns
Section titled “Returns”Relative strength index.
Remarks
Section titled “Remarks”- na values in the source series are ignored; the function calculates on the length quantity of non-na values.
Examples
Section titled “Examples”Example 1
Section titled “Example 1”//@version=6indicator("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)resplot(pine_rsi(close, 7))