Skip to content
Indicators 14 min read

Relative strength index (RSI): calculation and how to read it

How RSI is calculated with Wilder smoothing, a worked 14-session example, overbought and oversold readings, divergence, edge cases and limitations.

Hypothetical daily chart: price rises, pulls back and rises to a higher high, while RSI(14) in the pane below peaks lower on the second high before price declines.RSI above 70Higher highAB3070RSI(14)
Daily candles on hypothetical data with RSI(14). RSI stays above 70 for 13 consecutive sessions (shaded) while price keeps rising. Price then makes a higher high at B than at A, but RSI peaks lower: 72.8 at B against 81.8 at A, a bearish divergence. The decline that follows is one possible outcome, not a rule.

RSI compares the average size of recent gains with recent losses on a 0 to 100 scale. A high or low reading describes momentum that has already happened; it does not say when a move ends.

What RSI measures

The relative strength index, or RSI, is a momentum oscillator introduced by J. Welles Wilder Jr. in his 1978 book New Concepts in Technical Trading Systems. It compares the average size of recent up moves in the closing price with the average size of recent down moves and expresses the balance on a scale from 0 to 100. Above 50, average gains have outweighed average losses over the lookback; below 50, losses have.

RSI at a glance
PropertyRSI
InputClosing prices; on a daily chart, one close per session
Standard lookback14 periods, which on a daily chart means 14 sessions
Scale0 to 100, with 50 as the midline
Common reference levels70 and 30, as Wilder used them; some readers use 80 and 20
SmoothingWilder’s average, which gives each new change a weight of 1/14
First valueAfter 14 price changes, which takes 15 closes

Because each value keeps a fading memory of earlier changes, RSI responds gradually: a large move shifts it, but it does not jump the way a plain 14-session window would when an old value drops out. The name can also mislead. RSI does not compare a stock with the market or with other stocks; it looks only at one security’s own closes. Comparing a stock with a benchmark is a different measure, discussed further down this page.

How RSI is calculated

RSI is built from the change of each close against the prior close. Gains and losses are averaged separately with Wilder’s smoothing, and the ratio of the two averages is mapped onto the 0 to 100 scale.

change = close − prior close
gain = change if the change is positive, otherwise 0
loss = −change if the change is negative, otherwise 0
first average gain = (sum of the first 14 gains) ÷ 14
first average loss = (sum of the first 14 losses) ÷ 14
next average gain = (prior average gain × 13 + current gain) ÷ 14
next average loss = (prior average loss × 13 + current loss) ÷ 14
RS = average gain ÷ average loss
RSI = 100 − 100 ÷ (1 + RS)
RS
Wilder’s relative strength: the ratio of the average gain to the average loss. It involves no other security.
14 and 13
The lookback n and n − 1. Other settings replace them, for example 9 and 8.

Losses are recorded as positive numbers, so both averages are zero or above. The update gives the newest change a weight of 1/14 and the previous average 13/14, which makes Wilder’s average an exponential moving average with a smoothing factor of 1/14 = 0.071. That is slower than the 2 ÷ (14 + 1) = 0.133 factor of a standard 14-period EMA. Some software averages gains and losses with simple 14-session means instead; its values differ from Wilder’s, so confirm which version a platform uses before comparing numbers.

An equivalent form avoids the ratio: RSI = 100 × average gain ÷ (average gain + average loss). It returns the same value whenever the average loss is above zero, and it makes the edge cases easier to see.

Edge cases. If the average loss is 0 and the average gain is positive, RS would divide by zero, but the equivalent form gives exactly 100: RSI is 100 by definition. With Wilder’s smoothing that happens only when no close since the start of the calculation has been lower than the one before it, because the smoothing shrinks an old loss but never removes it. If both averages are 0, as in a perfectly flat series, the expression is 0 ÷ 0 and RSI is undefined; some charting software reports 50 by convention, which is a display choice rather than a calculated value. An average gain of 0 with any losses gives exactly 0.

A 14-session RSI calculation example

The tables below use 20 hypothetical daily closes, numbered from session 0. Session 0 only supplies the prior close for session 1, so sessions 1 to 14 provide the 14 changes behind the first RSI value.

Hypothetical closes, changes, gains and losses, sessions 0–14
SessionClose ($)Change ($)Gain ($)Loss ($)
050.00
150.40+0.400.400.00
250.15-0.250.000.25
350.70+0.550.550.00
451.10+0.400.400.00
550.85-0.250.000.25
651.30+0.450.450.00
751.95+0.650.650.00
851.60-0.350.000.35
952.05+0.450.450.00
1052.40+0.350.350.00
1152.10-0.300.000.30
1252.65+0.550.550.00
1353.10+0.450.450.00
1452.90-0.200.000.20
sum of gains, sessions 1–14 = 4.25; sum of losses = 1.35
first average gain = 4.25 ÷ 14 = 0.3036
first average loss = 1.35 ÷ 14 = 0.0964
RS = average gain ÷ average loss = 4.25 ÷ 1.35 = 3.1481
RSI = 100 − 100 ÷ (1 + 3.1481) = 75.89

From session 15 on, each average is updated with Wilder’s rule instead of being recomputed from a 14-session window.

Wilder smoothing after the first value, sessions 14–19
SessionClose ($)Gain ($)Loss ($)Average gainAverage lossRSRSI(14)
1452.900.000.200.30360.09643.148175.89
1553.450.550.000.32120.08953.586978.20
1653.200.000.250.29820.10102.952774.70
1752.600.000.600.27690.13662.026666.96
1852.950.350.000.28210.12692.223768.98
1953.500.550.000.30130.11782.557171.89

Session 15 shows the update: average gain = (0.3036 × 13 + 0.55) ÷ 14 = 0.3212 and average loss = (0.0964 × 13 + 0.00) ÷ 14 = 0.0895, so RSI rises to 78.20. The 0.60 loss in session 17 is the largest move in the table, yet RSI falls only from 74.70 to 66.96, because the new loss carries a weight of 1/14. Two gains then lift RSI back to 71.89 by session 19.

The example also shows how easily an orderly advance reaches the conventional overbought zone. Price rose 5.80% from session 0 to session 14, with 9 up sessions and 5 down sessions, and the first RSI value is already 75.89. A steady climb, not only a sharp spike, can produce a reading above 70.

Values are rounded for display. Each step uses the unrounded figures, so recomputing from the rounded averages can differ in the last digit.

How to read RSI on a stock chart

RSI is drawn in its own pane below the price chart, on a fixed 0 to 100 scale, usually with reference lines at 70 and 30. Before reading the line, confirm its period and the chart’s date range. If candles, ranges and volume are new to you, start with reading a stock chart.

  1. Locate RSI relative to 50. A line that holds above 50 for weeks describes a period in which average gains have exceeded average losses; below 50, the reverse.
  2. Compare RSI swings with price swings. A new price high with a higher RSI high shows momentum keeping pace; a new price high with a lower RSI high is a divergence.
  3. Watch the range RSI moves within. In a persistent advance, pullbacks often end with RSI well above 30, and in a persistent decline, rebounds often stall well below 70. A shift in that range describes a change in momentum.
  4. Treat 70 and 30 as context. A cross of either line records a strong run of gains or losses; it does not time a turn.
  5. Check the reading against price itself: the trend, nearby highs and lows, moving averages and volume.

In TradeClever, open Stock Charts and add the RSI pane. Its period is configurable, 14 by default, and the pane draws the 70 and 30 lines. To list stocks by their latest reading, CleverScan provides the field rsi14 and the function RSI(14), both Wilder’s 14-session RSI of daily closes.

How to interpret RSI overbought and oversold levels

Wilder treated readings above 70 as overbought and below 30 as oversold. The labels describe the recent balance of gains and losses, not a price that is too high or too low, and they are conventions rather than results of the formula. Some readers use 80 and 20 to flag only stronger extremes, and shorter lookbacks reach the extremes more often.

Common RSI levels expressed as RS
RSIRS (average gain ÷ average loss)What the level describes
804.00Average gains four times as large as average losses
702.33Average gains a little over twice average losses
501.00Average gains equal to average losses
300.43Average losses a little over twice average gains
200.25Average losses four times as large as average gains

Used this way, the levels become a filter for a question you already have. A stock in a long-term advance whose RSI drops below 30 has had an unusually strong run of losses for that trend. Whether the trend then resumes is a separate question for price, volume and context.

securityType = "Stock" and rsi14 < 30 and close > sma200

Stocks whose 14-session RSI is below 30 while the close is above the 200-session simple moving average: short-term weakness inside a longer advance, listed for study rather than as a trading instruction.

Why overbought stocks can keep rising and oversold stocks keep falling

RSI measures momentum that has already happened. During a strong trend, the forces that pushed RSI above 70, or below 30, can stay in place, so an extreme reading can last for many sessions while price keeps moving in the same direction.

  • The averages are slow by design. With Wilder’s smoothing, a single down session lowers the average gain by a small fraction, so RSI stays high as long as gains keep outweighing losses.
  • The scale compresses near its ends. Moving RSI from 70 to 80 requires RS to rise from 2.33 to 4.00, and reaching 90 requires 9.00, so a strong advance can sit in the 70s for a long time.
  • Overbought is not overvalued. RSI uses closes only and knows nothing about earnings, valuation or news, any of which can sustain a trend.
  • The thresholds are not turning points. Nothing in the calculation makes 70 or 30 a level where price must react.

The illustration on this page shows the pattern on hypothetical data: RSI stays above 70 for 13 consecutive sessions during the first advance while price keeps climbing. The same logic applies in reverse to a decline that holds RSI below 30.

An RSI above 70 during an advance is consistent with a strong trend. It is a reason to look more closely, not evidence that the advance is ending.

RSI divergence: bullish, bearish and hidden

A divergence occurs when price and RSI disagree about a swing. You compare two swing highs, or two swing lows, on the price chart with the RSI values at the same sessions. Divergence describes momentum that is fading or building; it can persist through several swings before price changes direction, and sometimes price never does.

Regular and hidden RSI divergence
TypePriceRSIUsual reading
BearishHigher highLower highUpward momentum is fading
BullishLower lowHigher lowDownward momentum is fading
Hidden bullishHigher lowLower lowA pullback inside an advance; read by some as continuation
Hidden bearishLower highHigher highA rebound inside a decline; read by some as continuation

Bearish divergence. In the illustration, price closes at 50.02 at high A and at 51.28 at high B, a higher high. RSI reads 81.8 at A and only 72.8 at B. The second advance lifted price with smaller gains relative to losses than the first, which is exactly what the divergence records.

Bullish divergence is the mirror image. A lower price low with a higher RSI low means the second decline came with smaller losses relative to gains. It describes slowing downside momentum, not a bottom.

Hidden divergence reverses the comparison. Regular divergence is usually read as a sign that a trend is losing momentum. Hidden divergence, a higher price low with a lower RSI low in an advance, or a lower price high with a higher RSI high in a decline, is read by some as a sign that a move against the trend was weak. Both depend on which swings you pick, so define the swings first, for example the highest close of each rally, and only then read RSI.

Divergence can repeat. Price can make a third and a fourth higher high, each with a lower RSI high, while the trend continues. Treat divergence as a description of momentum, and confirm any change with price itself.

RSI versus relative strength against the market

Despite the name, RSI does not compare a stock with an index. The relative strength line, also called comparative relative strength, divides a stock’s price by a benchmark’s price. It rises when the stock outperforms the benchmark and falls when the stock lags, whatever the direction of either.

Relative strength index versus relative strength line
AspectRelative strength index (RSI)Relative strength line
InputsOne security’s closesA security’s price and a benchmark’s price
QuestionHave recent gains outweighed recent losses?Has the stock done better or worse than the benchmark?
ScaleBounded, 0 to 100Unbounded ratio; its direction and changes carry the information
Typical useMomentum and its extremesLeaders and laggards against an index or sector

The two can disagree. A stock that rises steadily while the market rises faster can show a high RSI and a falling relative strength line at the same time. In CleverScan, rsi14 is the RSI of a stock’s own closes, while rsRating is a 1 to 100 percentile of weighted 12-month relative strength, so it compares a stock with other stocks. The rule below combines the two questions.

securityType = "Stock" and rsRating >= 80 and rsi14 < 50

Stocks in the top fifth by RS Rating whose 14-session RSI is below 50: relative leaders over a year that have had a softer few weeks.

RSI compared with MACD, the stochastic oscillator and MFI

RSI is often read next to other momentum tools. They overlap, and each answers a slightly different question, so two of them agreeing is less independent confirmation than it looks.

RSI and related momentum indicators
IndicatorInputsScaleWhat it measuresCommon settings
RSICloses0 to 100Average gains versus average losses14 periods; 70 and 30
MACDClosesUnbounded, in price unitsThe gap between a fast and a slow EMA12, 26 and 9 periods
Stochastic oscillatorHighs, lows and closes0 to 100The position of the close within the recent high–low range14, 3 and 3; 80 and 20
Money flow indexHighs, lows, closes and volume0 to 100An RSI-style ratio of volume-weighted price flows14 periods; 80 and 20

RSI versus MACD. MACD is measured in the stock’s price units, so a MACD of 2 means something different for a $20 stock and a $400 stock, while RSI’s bounded scale compares across stocks. MACD is built from moving averages and mainly describes the direction of a trend and changes in it; RSI describes the balance of up and down closes and its extremes. Many readers use MACD for the trend question and RSI for the stretch question on the same chart.

RSI versus the stochastic oscillator. The stochastic ignores the size of each change and asks only where the latest close sits between the highest high and the lowest low of the lookback. It reads 100 whenever a close equals the highest high in the window, while RSI approaches 100 only after a long, nearly unbroken run of gains. The stochastic is therefore the more sensitive of the two and reaches its extremes much more often.

RSI versus the money flow index. MFI, developed by Gene Quong and Avrum Soudack, applies an RSI-style ratio to the typical price multiplied by volume, so heavy-volume sessions weigh more. MFI and RSI can disagree when large price moves happen on light volume, or small moves on heavy volume.

Limitations of RSI

RSI condenses recent closes into one number, and what it leaves out matters as much as what it keeps.

  • It uses closes only. Intraday highs and lows, moves that reverse within the session and volume do not enter the calculation.
  • It depends on its settings. A 2-session and a 14-session RSI on the same chart can disagree, and simple-average versions differ from Wilder’s.
  • It depends on its starting point. Wilder’s smoothing remembers every earlier change with a shrinking weight, so values from a short series differ slightly from values computed over a longer one until that memory fades.
  • Extremes persist in trends, and divergences can repeat before any reversal.
  • Shared scales are not shared meanings. An RSI of 70 and a stochastic reading of 70 describe different things.
  • No threshold is a tested rule. A rule built on RSI levels needs its own evidence across many stocks and periods.

TradeClever’s Backtest Scan, inside the CleverScan editor, is one way to examine such a rule. It selects the stocks that matched on a past session and reports their price returns to the end date you choose, with their equal-weight average. It is an event study, not a trading simulation, and a past result does not establish future performance.

Sources

  • J. Welles Wilder Jr., New Concepts in Technical Trading Systems (1978)

Read our data and methodology notes for calculation context. This guide explains research tools and observations. It does not recommend a trade or investment.

Follow your curiosity

One good question leads to another.

All guides
Make room for better research

Put your curiosity to work.

Build a scan with filters or CleverScan rules. Explore the results. Find your next idea.

Open a stock chart