RSI (Relative Strength Index)

RSI shows the speed and strength of recent price moves on a 0 to 100 scale and is one of the most widely used oscillators in technical analysis.

What it is

The Relative Strength Index was introduced by J. Welles Wilder in 1978. It compares how strong recent up candles have been against down candles and shows the result on a 0 to 100 scale, in a pane under the chart.

How it's calculated

  1. Wilder-smoothed averages of the gains and of the losses over the last 14 candles are calculated.
  2. Their ratio is the relative strength (RS).
  3. RSI = 100 − 100 ÷ (1 + RS)

How traders read it

  • Above 70 is usually called overbought and below 30 oversold, but in strong trends RSI can stay there for a long time.
  • Crossing 50 shows which side, buyers or sellers, has the upper hand.
  • Divergence: when price makes a higher high but RSI a lower high, the trend's momentum has slowed.
  • In uptrends RSI tends to swing between about 40 and 80, and in downtrends between about 20 and 60.

Settings

The default length is 14. A shorter length (say 7) is more sensitive, with more signals and more errors; a longer one (21) is calmer. Some traders use 80 and 20 instead of 70 and 30 in volatile markets.

Where it misleads

  • Selling just because RSI is above 70 in a strong uptrend is one of the most common beginner losses.
  • Divergence doesn't time the turn; wait for price to confirm before entering.

Its Pine Script on Vlevel

This is the script the chart runs. In the chart's indicators window you can open it, change it and save your own copy.

Relative Strength Index · Pine Script v6
//@version=6
indicator("Relative Strength Index", shorttitle = "RSI", format = format.price, precision = 2)
length = input.int(14, "RSI Length", minval = 1)
src    = input.source(close, "Source")
maKind = input.string("None", "MA Type", options = ["None", "SMA", "EMA", "SMMA (RMA)", "WMA", "VWMA"], group = "Smoothing", display = display.none)
maLen  = input.int(14, "MA Length", minval = 1, group = "Smoothing", display = display.none)
change = ta.change(src)
up     = ta.rma(math.max(change, 0), length)
down   = ta.rma(-math.min(change, 0), length)
rsi    = down == 0 ? 100 : up == 0 ? 0 : 100 - (100 / (1 + up / down))
ma(float src, int len, string kind) =>
    switch kind
        "SMA" => ta.sma(src, len)
        "EMA" => ta.ema(src, len)
        "SMMA (RMA)" => ta.rma(src, len)
        "WMA" => ta.wma(src, len)
        "VWMA" => ta.vwma(src, len)
        => ta.sma(src, len)
plot(rsi, "RSI", color = #c084fc)
plot(maKind != "None" ? ma(rsi, maLen, maKind) : na, "RSI-based MA", color = #f5c542)
hline(70, "Upper Band", color = color.new(color.white, 75), linestyle = hline.style_dashed)
hline(50, "Middle Band", color = color.new(color.white, 75), linestyle = hline.style_dotted)
hline(30, "Lower Band", color = color.new(color.white, 75), linestyle = hline.style_dashed)

Indicators describe past prices; none predicts the future. For education, not investment advice.