rsi

Relative Strength Index

rsi(source, periods, matype="wilder")

Parameters

Name Type Description
source field Data series (commonly close)
periods int Number of periods (commonly 14)
matype str, optional Smoothing type ["wilder", "sma", "ema"], default "wilder"

Formula

```
RSI = 100 - (100 / (1 + RS))
RS = Avg Gain / Avg Loss
Avg Gain = MA(gain(source), periods)
Avg Loss = MA(loss(source), periods)
```

Examples

// overbought condition (RSI above 70)
rsi(close, 14) > 70;

// oversold condition (RSI below 30)
rsi(close, 14) < 30;

// RSI exiting overbought zone
crossunder(rsi(close, 14), 70);

// RSI with EMA smoothing instead of Wilder
rsi(close, 14, matype="ema") > 50;

Returns

Float 0-100 (>70 overbought, <30 oversold)