rsi
Relative Strength Index
rsi(source, periods, matype="wilder")
Parameters
Relative Strength Index - rsi(source, periods, matype="wilder")
Momentum oscillator measuring overbought/oversold conditions.
- 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
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)