A momentum oscillator that measures the speed and size of recent price changes on a 0-100 scale.
RSI is a momentum oscillator developed by J. Welles Wilder Jr. and introduced in 1978 in his book New Concepts in Technical Trading Systems. It compares the magnitude of recent gains to recent losses over a set lookback period (most commonly 14 bars) and expresses the result as a single line that moves between 0 and 100. It is plotted in a separate pane below the price chart, usually with reference levels drawn at 30 and 70. RSI is descriptive, not predictive: it summarizes how price has behaved recently and gives no guarantee about what price will do next. No indicator can forecast price, and all trading carries risk of loss.
RSI looks back over a chosen number of bars (14 by default) and separates the price changes into upward moves and downward moves. It calculates an average of the up moves and an average of the down moves using Wilder's smoothing method (a running average closely related to an exponential moving average), so each new bar updates the running averages rather than recalculating them from scratch. The ratio of average gain to average loss (called relative strength) is then converted into a 0-100 reading. When recent gains dominate, the line rises toward 100; when recent losses dominate, it falls toward 0; when gains and losses are roughly balanced, it sits near 50. Shorter periods make the line more reactive and choppy; longer periods make it smoother and slower.
Default length 14 on the closing price, with reference lines at 30 and 70 and an optional midline at 50. Shorter lengths (such as 7-9) are sometimes used for a faster, noisier reading; longer lengths (such as 21-25) for a smoother, slower one. Some traders watch 80/20 instead of 70/30 to reduce noisy readings in trending markets. RSI can be applied to any timeframe.
//@version=6
indicator("RSI Example", overlay = false)
length = input.int(14, "RSI Length", minval = 1)
src = input.source(close, "Source")
myRsi = ta.rsi(src, length)
plot(myRsi, "RSI", color = color.blue)
hline(70, "Overbought", color = color.gray)
hline(50, "Midline", color = color.new(color.gray, 50))
hline(30, "Oversold", color = color.gray)Pro tip: Treat the 30/70 levels as descriptions of stretched momentum, not as triggers. RSI tends to be most informative when read in the context of the prevailing trend — for example, in an uptrend some traders watch whether pullbacks hold above the midline rather than waiting for a dip below 30. Pair it with price structure and a defined risk plan; this is educational context only, and no indicator removes the risk of loss.
Educational only — not financial advice, not a recommendation to trade. No indicator is predictive; trading involves substantial risk of loss.