What the RSI calculator does
The Relative Strength Index, introduced by J. Welles Wilder in 1978, compares the size of recent up-moves with recent down-moves and scales the result between 0 and 100. Paste closing prices and the calculator returns the current RSI together with the numbers behind it: the average gain, the average loss and their ratio RS, the overbought or oversold reading, and a table of the last 20 values.
It uses Wilder's smoothing exactly as TradingView's ta.rsi does, so you can verify a value on your chart, in a spreadsheet or in code you wrote.
How to use it
- Paste closing prices separated by commas, spaces or new lines. Dates and headers are skipped.
- Choose the order of the list: oldest first or newest first.
- Set the length. Wilder used 14 periods, still the default on most platforms.
- Adjust the overbought and oversold levels if you use others than 70 and 30; some traders prefer 80 and 20 on fast markets.
RSI(14) needs at least 15 closes, because it works on the 14 changes between them. For values that match a chart to the decimal, paste about ten times the length or more, 140 closes for RSI(14).
The formula
change = close − previous close
gain = change if it is positive, otherwise 0
loss = −change if it is negative, otherwise 0
first average gain = mean of the first N gains (same for losses)
next average gain = (previous average × (N − 1) + gain) ÷ N
RS = average gain ÷ average loss
RSI = 100 − 100 ÷ (1 + RS)
The recursive step is Wilder's smoothing, an exponential average with α = 1 ÷ N (ta.rma in Pine Script). When the average loss is zero, RSI is 100; when the average gain is zero, it is 0.
Worked example
The sample loaded in the calculator is the classic 33-close series used to illustrate Wilder's RSI, with a length of 14:
- The first 14 changes give an average gain of 0.2384 and an average loss of 0.0996. RS ≈ 2.394, so the first RSI is 100 − 100 ÷ 3.394 = 70.53, right on the overbought line.
- The next close falls by 0.2792. The average gain becomes (0.2384 × 13 + 0) ÷ 14 = 0.2214 and the average loss (0.0996 × 13 + 0.2792) ÷ 14 = 0.1124, so RSI drops to 66.32.
- After the sell-off at the end of the list, the RSI bottoms at 33.08 and ends at 37.77 with a last gain of 0.4686: weak, but not oversold.
How to read the RSI
- Above 70: gains have clearly outweighed losses over the window, the "overbought" zone. In a strong uptrend RSI can stay above 70 for a long time; it measures momentum, not a turning point.
- Below 30: the "oversold" zone, with the same caveat in downtrends.
- Around 50: gains and losses are balanced. Some traders use above or below 50 as a momentum filter for other signals.
- Divergence: price makes a new high while RSI makes a lower high, or the reverse. It shows fading momentum, and it can last a long time before price turns. See how to build an RSI divergence indicator.
Any rule built on these readings is a hypothesis until it is backtested with costs. Size each trade from its stop distance, not from the RSI value, with the position size calculator.
Why your chart may show a slightly different RSI
- Smoothing memory. Wilder's averages keep a fading memory of every earlier change, shrinking by a factor of (1 − 1 ÷ N) per bar. With 140 closes for RSI(14), the starting point's weight falls below 0.01%, invisible at two decimals. With only 30 closes, the first values can differ from a chart that has years of history.
- Another method. Some spreadsheets and platforms use simple averages of gains and losses (Cutler's RSI) or an EMA with α = 2 ÷ (N + 1). Both give different numbers from Wilder's RSI.
- An open bar. The RSI of the current bar keeps moving until the bar closes.
- Different data. Brokers' feeds differ slightly, and daily forex bars close at different hours depending on the feed.
Common mistakes
- Selling every reading above 70. In trends, the overbought zone is where momentum is strongest.
- Comparing RSIs of different lengths. RSI(7) reaches the extremes far more often than RSI(21).
- Too few closes. The calculator shows a value from N + 1 closes, but it only settles once enough history is behind it.