---
title: "RSI Formula: How to Calculate RSI, with Free Excel Sheet · MyAlgoMate"
source: https://myalgomate.com/indicators/rsi-formula
retrieved: 2026-11-27
publisher: MyAlgoMate (Myalgomate Technologies LLP, Rajkot, India)
---

1. [Home](https://myalgomate.com/)
2. [Indicator formulas](https://myalgomate.com/indicators)
3. RSI formula

// INDICATOR FORMULA

# RSI formula: how to calculate RSI (with Excel)

How the Relative Strength Index is worked out, step by step — Wilder's averages of the up-moves and down-moves in the close over 14 candles, turned into a number between 0 and 100. With a worked example, the Excel formulas, a free Excel sheet and a box to calculate RSI from your own prices.

Last updated: 27 November 2026

[Download the free RSI Excel sheet (.xlsx)](https://myalgomate.com/downloads/indicators/myalgomate-rsi-calculation.xlsx)

Needs: closing prices · Standard settings: Period 14

Formula Step by step Worked example & calculator In Excel Questions

## The RSI formula

```
Change = Close − previous Close
Gain   = Change, if it is above 0 (otherwise 0)
Loss   = −Change, if it is below 0 (otherwise 0)

First average gain = average of the first 14 gains
First average loss = average of the first 14 losses
Next average gain  = (previous average gain × 13 + current gain) ÷ 14
Next average loss  = (previous average loss × 13 + current loss) ÷ 14

RS  = Average gain ÷ Average loss
RSI = 100 − 100 ÷ (1 + RS)
```

The 13 and 14 come from the period: for RSI *n* they are *n* − 1 and *n*. This running average is **Wilder's smoothing** (often called RMA), the method J. Welles Wilder published with RSI in 1978 and the one most charts use. If the average loss is 0 — no down candles in the window — RSI is 100.

“Gain” and “loss” are the standard names in the RSI formula for how much the closing price rose or fell from one candle to the next. They are price changes, not anyone's profit or loss.

## How to calculate RSI step by step

1. **List the closing prices, oldest first.** In the example, Day 1 closed at 1,001.15 and Day 2 at 987.95.
2. **Work out each candle's change and split it into a gain or a loss.** Day 2: 987.95 − 1,001.15 = −13.20, so the gain is 0 and the loss is 13.20. Day 3 rose by 21.20, so its gain is 21.20 and its loss is 0.
3. **Average the first 14 gains and the first 14 losses.** The first 14 changes are Day 2 to Day 15, so the first averages appear on Day 15: average gain 9.5643, average loss 5.1107.
4. **Turn them into RS and RSI.** RS = 9.5643 ÷ 5.1107 = 1.8714, and RSI = 100 − 100 ÷ (1 + 1.8714) = **65.17**.
5. **From the next candle on, smooth the averages.** Day 16 fell by 33.30: average gain = (9.5643 × 13 + 0) ÷ 14 = 8.8811; average loss = (5.1107 × 13 + 33.30) ÷ 14 = 7.1242. RSI = **55.49**.
6. **Repeat for every candle.** By Day 60 the example's RSI (14) is 69.67.

## Worked example — and calculate RSI from your own prices

The table works through 60 daily candles of an imaginary stock, column by column — the same columns as the Excel sheet. To calculate RSI for your own stock, clear the box and paste your closing prices from Excel or your broker's download.

Your prices: CloseOne row per candle, oldest first. Paste straight from Excel or your broker's download; a date or time column becomes the row label. Filled with our example prices.

Clear

Period

Latest values

RSI (14): 69.67

| Day | Close | Change | Gain | Loss | Avg gain | Avg loss | RS | RSI (14) |
| --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Day 1 | 1,001.15 |  |  |  |  |  |  |  |
| Day 2 | 987.95 | −13.20 | 0.00 | 13.20 |  |  |  |  |
| Day 3 | 1,009.15 | 21.20 | 21.20 | 0.00 |  |  |  |  |
| Day 4 | 1,012.60 | 3.45 | 3.45 | 0.00 |  |  |  |  |
| Day 5 | 993.25 | −19.35 | 0.00 | 19.35 |  |  |  |  |
| Day 6 | 1,008.60 | 15.35 | 15.35 | 0.00 |  |  |  |  |
| Day 7 | 1,013.60 | 5.00 | 5.00 | 0.00 |  |  |  |  |
| Day 8 | 1,001.55 | −12.05 | 0.00 | 12.05 |  |  |  |  |
| Day 9 | 1,031.55 | 30.00 | 30.00 | 0.00 |  |  |  |  |
| Day 10 | 1,040.05 | 8.50 | 8.50 | 0.00 |  |  |  |  |
| Day 11 | 1,033.15 | −6.90 | 0.00 | 6.90 |  |  |  |  |
| Day 12 | 1,064.80 | 31.65 | 31.65 | 0.00 |  |  |  |  |
| Day 13 | 1,083.55 | 18.75 | 18.75 | 0.00 |  |  |  |  |
| Day 14 | 1,067.95 | −15.60 | 0.00 | 15.60 |  |  |  |  |
| Day 15 | 1,063.50 | −4.45 | 0.00 | 4.45 | 9.5643 | 5.1107 | 1.8714 | 65.17 |
| Day 16 | 1,030.20 | −33.30 | 0.00 | 33.30 | 8.8811 | 7.1242 | 1.2466 | 55.49 |
| Day 17 | 1,012.20 | −18.00 | 0.00 | 18.00 | 8.2468 | 7.9011 | 1.0438 | 51.07 |
| Day 18 | 981.60 | −30.60 | 0.00 | 30.60 | 7.6577 | 9.5224 | 0.8042 | 44.57 |
| Day 19 | 970.55 | −11.05 | 0.00 | 11.05 | 7.1107 | 9.6315 | 0.7383 | 42.47 |
| Day 20 | 960.90 | −9.65 | 0.00 | 9.65 | 6.6028 | 9.6329 | 0.6854 | 40.67 |
| Day 21 | 978.30 | 17.40 | 17.40 | 0.00 | 7.3740 | 8.9448 | 0.8244 | 45.19 |
| Day 22 | 958.85 | −19.45 | 0.00 | 19.45 | 6.8473 | 9.6952 | 0.7063 | 41.39 |
| Day 23 | 946.75 | −12.10 | 0.00 | 12.10 | 6.3582 | 9.8669 | 0.6444 | 39.19 |
| Day 24 | 937.95 | −8.80 | 0.00 | 8.80 | 5.9041 | 9.7907 | 0.6030 | 37.62 |
| Day 25 | 927.85 | −10.10 | 0.00 | 10.10 | 5.4824 | 9.8128 | 0.5587 | 35.84 |
| Day 26 | 911.20 | −16.65 | 0.00 | 16.65 | 5.0908 | 10.3012 | 0.4942 | 33.07 |
| Day 27 | 905.15 | −6.05 | 0.00 | 6.05 | 4.7271 | 9.9975 | 0.4728 | 32.10 |
| Day 28 | 885.95 | −19.20 | 0.00 | 19.20 | 4.3895 | 10.6549 | 0.4120 | 29.18 |
| Day 29 | 874.70 | −11.25 | 0.00 | 11.25 | 4.0759 | 10.6974 | 0.3810 | 27.59 |
| Day 30 | 855.80 | −18.90 | 0.00 | 18.90 | 3.7848 | 11.2833 | 0.3354 | 25.12 |
| Day 31 | 862.15 | 6.35 | 6.35 | 0.00 | 3.9680 | 10.4773 | 0.3787 | 27.47 |
| Day 32 | 866.45 | 4.30 | 4.30 | 0.00 | 3.9917 | 9.7289 | 0.4103 | 29.09 |
| Day 33 | 845.10 | −21.35 | 0.00 | 21.35 | 3.7066 | 10.5590 | 0.3510 | 25.98 |
| Day 34 | 851.55 | 6.45 | 6.45 | 0.00 | 3.9026 | 9.8048 | 0.3980 | 28.47 |
| Day 35 | 860.20 | 8.65 | 8.65 | 0.00 | 4.2417 | 9.1045 | 0.4659 | 31.78 |
| Day 36 | 854.80 | −5.40 | 0.00 | 5.40 | 3.9387 | 8.8399 | 0.4456 | 30.82 |
| Day 37 | 877.20 | 22.40 | 22.40 | 0.00 | 5.2574 | 8.2084 | 0.6405 | 39.04 |
| Day 38 | 888.45 | 11.25 | 11.25 | 0.00 | 5.6854 | 7.6221 | 0.7459 | 42.72 |
| Day 39 | 905.40 | 16.95 | 16.95 | 0.00 | 6.4900 | 7.0777 | 0.9170 | 47.83 |
| Day 40 | 896.80 | −8.60 | 0.00 | 8.60 | 6.0265 | 7.1864 | 0.8386 | 45.61 |
| Day 41 | 889.60 | −7.20 | 0.00 | 7.20 | 5.5960 | 7.1874 | 0.7786 | 43.78 |
| Day 42 | 895.30 | 5.70 | 5.70 | 0.00 | 5.6034 | 6.6740 | 0.8396 | 45.64 |
| Day 43 | 919.00 | 23.70 | 23.70 | 0.00 | 6.8960 | 6.1973 | 1.1127 | 52.67 |
| Day 44 | 918.35 | −0.65 | 0.00 | 0.65 | 6.4035 | 5.8011 | 1.1038 | 52.47 |
| Day 45 | 906.25 | −12.10 | 0.00 | 12.10 | 5.9461 | 6.2510 | 0.9512 | 48.75 |
| Day 46 | 932.10 | 25.85 | 25.85 | 0.00 | 7.3678 | 5.8045 | 1.2693 | 55.93 |
| Day 47 | 944.35 | 12.25 | 12.25 | 0.00 | 7.7165 | 5.3899 | 1.4317 | 58.88 |
| Day 48 | 948.70 | 4.35 | 4.35 | 0.00 | 7.4760 | 5.0049 | 1.4937 | 59.90 |
| Day 49 | 966.35 | 17.65 | 17.65 | 0.00 | 8.2028 | 4.6474 | 1.7650 | 63.83 |
| Day 50 | 955.60 | −10.75 | 0.00 | 10.75 | 7.6168 | 5.0833 | 1.4984 | 59.97 |
| Day 51 | 969.10 | 13.50 | 13.50 | 0.00 | 8.0371 | 4.7202 | 1.7027 | 63.00 |
| Day 52 | 984.35 | 15.25 | 15.25 | 0.00 | 8.5523 | 4.3830 | 1.9512 | 66.12 |
| Day 53 | 980.90 | −3.45 | 0.00 | 3.45 | 7.9414 | 4.3164 | 1.8398 | 64.79 |
| Day 54 | 962.50 | −18.40 | 0.00 | 18.40 | 7.3742 | 5.3224 | 1.3855 | 58.08 |
| Day 55 | 960.20 | −2.30 | 0.00 | 2.30 | 6.8474 | 5.1065 | 1.3409 | 57.28 |
| Day 56 | 967.35 | 7.15 | 7.15 | 0.00 | 6.8690 | 4.7417 | 1.4486 | 59.16 |
| Day 57 | 971.00 | 3.65 | 3.65 | 0.00 | 6.6391 | 4.4030 | 1.5078 | 60.13 |
| Day 58 | 981.75 | 10.75 | 10.75 | 0.00 | 6.9327 | 4.0885 | 1.6957 | 62.90 |
| Day 59 | 994.85 | 13.10 | 13.10 | 0.00 | 7.3733 | 3.7965 | 1.9421 | 66.01 |
| Day 60 | 1,012.35 | 17.50 | 17.50 | 0.00 | 8.0966 | 3.5253 | 2.2967 | 69.67 |

Copy results (CSV)Everything is worked out in your browser. Nothing you paste is stored or sent.

The example prices are made up for this page — they are not real market data. RSI is a calculation from past prices, not a forecast, a signal or advice to buy or sell. MyAlgoMate provides trading technology, not investment advice.

## How to calculate RSI in Excel

Put the headings in row 1 and the first candle in row 2, oldest at the top. Then type these formulas — each column uses the ones to its left:

1. A Day A2 downwards: your dates, oldest at the top.
2. B Close B2 downwards: the closing prices, oldest at the top.
3. C Change C3 `=B3-B2` — then copy it down to the last row.
4. D Gain D3 `=MAX(C3,0)` — then copy it down to the last row.
5. E Loss E3 `=MAX(-C3,0)` — then copy it down to the last row.
6. F Avg gain F16 `=AVERAGE(D3:D16)` — this cell only (the starting value). F17 `=(F16*13+D17)/14` — then copy it down to the last row.
7. G Avg loss G16 `=AVERAGE(E3:E16)` — this cell only (the starting value). G17 `=(G16*13+E17)/14` — then copy it down to the last row.
8. H RS H16 `=IF(G16=0,"",F16/G16)` — then copy it down to the last row.
9. I RSI (14) I16 `=IF(G16=0,100,100-100/(1+F16/G16))` — then copy it down to the last row.

Rows 2 to 15 have no RSI: the first value needs 14 changes. The only difference between row 16 and the rows below it is the averaging — a plain AVERAGE once, then the smoothing formula.

Prefer not to type them? The free sheet has every formula filled in for the example prices — replace the prices with yours and extend the rows. It opens in Microsoft Excel (we checked every value against the table above), and you can import it into Google Sheets or LibreOffice.

[Download the free RSI Excel sheet (.xlsx)](https://myalgomate.com/downloads/indicators/myalgomate-rsi-calculation.xlsx)

## What the RSI number shows

RSI compares the size of recent up-moves with recent down-moves on a scale from 0 to 100. At 50 the average gain and the average loss are equal; above 50 the average gain is the larger one, below 50 the average loss is. It reaches 100 only when there were no losses at all in the window, and 0 only when there were no gains.

Many charts draw lines at 70 and 30, the levels commonly labelled “overbought” and “oversold”. They are reference lines on the scale, not instructions — RSI describes past prices, and what you do with it is your own decision.

## MACD and RSI: how they differ and how they are read together

Both indicators start from the same closing prices, but they are built differently and describe different things. The table sets them side by side; the full formula for the other one is on the [MACD formula page](https://myalgomate.com/indicators/macd-formula).

|  | RSI (14) | MACD (12, 26, 9) |
| --- | --- | --- |
| What it measures | Size of recent up-moves against down-moves | Gap between a faster and a slower moving average: direction and speed of the trend |
| Built from | Wilder's average gain and average loss | Two exponential averages (EMA 12 and EMA 26) and a 9-candle EMA of their gap |
| Scale | Fixed, 0 to 100 | No fixed range; moves around a zero line, in price units |
| Reference lines on charts | 50, and lines at 30 and 70 | The zero line and the signal line |
| Parts | One line | MACD line, signal line, histogram |
| Both are | Worked out from past closing prices only, so both lag the price and neither forecasts it |  |

**Side by side, on the same prices.** The table below takes four days of this page's imaginary stock and shows both indicators for the same close. It is arithmetic from the worked example, not real market data.

| Day | Close | RSI (14) | MACD line | Signal | Histogram |
| --- | --- | --- | --- | --- | --- |
| Day 34 | 851.55 | 28.47 | −49.6827 | −45.3296 | −4.3531 |
| Day 40 | 896.80 | 45.61 | −31.4433 | −40.3944 | 8.9511 |
| Day 50 | 955.60 | 59.97 | 2.6206 | −10.7132 | 13.3338 |
| Day 60 | 1,012.35 | 69.67 | 17.8758 | 11.2317 | 6.6442 |

Across Day 34 to Day 60 of the example (every day where both have a value), RSI is above 50 and the MACD line is above zero, or both are on the other side, on 22 of 27 days. On the other 5 they sit on opposite sides. The two are built from different parts of the price history, so they do not always agree, and a day where they differ is not an error.

People who put both on one chart usually describe it this way: MACD is read for the direction and strength of the trend, RSI for how strong recent up-moves are compared with down-moves. That describes how the indicators are commonly read; it is not a rule, a signal or a recommendation to buy or sell. Neither indicator predicts what price does next.

## Why your RSI may not match your chart

- **How much history went in.** The smoothing never fully forgets earlier candles, so start from more history than you need — the difference fades as you add candles.
- **Simple averages instead of Wilder's.** Some tools (“Cutler's RSI”) use a plain 14-candle average every time; the numbers come out different.
- **Different prices.** Spot vs futures, a different timeframe, or a chart that adjusts past prices for splits and bonuses.
- **A different period.** RSI 9 or RSI 21 move differently from RSI 14 — check the setting.

## Simple-average RSI (Cutler's version)

If you need the simple-average version, replace the two smoothing formulas with plain averages of the last 14:

```
Average gain = AVERAGE(last 14 gains)
Average loss = AVERAGE(last 14 losses)
RSI = 100 − 100 ÷ (1 + Average gain ÷ Average loss)
```

In the Excel sheet that means putting =AVERAGE(D3:D16) in F16 and copying it down (and the same for column G). Related: the [stochastic formula](https://myalgomate.com/indicators/stochastic-formula) (used in Stochastic RSI) and the [EMA formula](https://myalgomate.com/indicators/ema-formula), which Wilder's smoothing resembles.

// FAQ

## RSI calculation — questions, answered.

How is RSI calculated?

Work out each candle's change from the previous close and split it into a gain or a loss. Average the first 14 gains and the first 14 losses, then keep both averages going with Wilder's smoothing: (previous average × 13 + today's value) ÷ 14. RS is the average gain divided by the average loss, and RSI = 100 − 100 ÷ (1 + RS).

How do I calculate RSI in Excel?

Put dates in column A and closes in column B from row 2. In C3 type =B3-B2 (the change), in D3 =MAX(C3,0) (gain) and in E3 =MAX(-C3,0) (loss), and copy them down. The first averages go in row 16: =AVERAGE(D3:D16) and =AVERAGE(E3:E16). From row 17: =(F16*13+D17)/14 and =(G16*13+E17)/14. RSI in I16: =IF(G16=0,100,100-100/(1+F16/G16)), copied down. The free sheet on this page has all of it filled in.

Why is my RSI different from the one on TradingView or my broker's chart?

Usually because of the starting point. Wilder's smoothing carries a little of every earlier candle forward, so RSI worked out from 60 candles differs slightly from RSI worked out from 1,000 candles of the same stock — the gap shrinks as you add history. Other causes: a different period, spot vs futures prices, a different timeframe, or a chart that uses simple averages instead of Wilder's smoothing.

How many candles do I need to calculate RSI 14?

At least 15 closes — 14 changes need 15 prices — for the first value. To match a chart closely, use much more history: 100 or more candles before the date you are checking is a sensible amount, because the smoothing needs time to settle.

What is Wilder's smoothing (RMA)?

It is the averaging J. Welles Wilder used when he published RSI in 1978: new average = (previous average × (n − 1) + new value) ÷ n. It works like an exponential moving average with a weight of 1 ÷ n (1 ÷ 14 for RSI 14), so it reacts more slowly than a standard EMA of the same length. Many charting tools call it RMA or SMMA.

What is Stochastic RSI and how is it calculated?

Stochastic RSI applies the stochastic formula to RSI values instead of prices: StochRSI = (RSI − lowest RSI of the last 14) ÷ (highest RSI of the last 14 − lowest RSI of the last 14). Charts usually smooth it with a 3-period average (%K) and average that again (%D). So you calculate RSI first, exactly as on this page, then apply the stochastic step to the RSI column.

What is the difference between MACD and RSI?

They measure different things from the same closing prices. MACD is the gap between a 12-candle and a 26-candle exponential average, with a 9-candle signal line, so it follows the direction and speed of the trend and can be above or below zero. RSI compares the size of recent up-moves with recent down-moves and always sits between 0 and 100. MACD has no fixed top or bottom; RSI does. Neither one is a forecast.

Can MACD and RSI be used together?

Many people put both on one chart because they answer different questions: MACD describes the trend's direction and strength, RSI describes how strong recent up-moves are compared with down-moves. This page only explains how each is calculated and how they are commonly read. It does not tell you when to buy or sell, and a reading from either indicator is not a signal or advice.

Which is better, MACD or RSI?

Neither is better; they are built differently. MACD is made from moving averages and has no fixed range, RSI is a 0 to 100 scale made from average gains and losses. Both are calculated from past prices and both lag the price. Which one you look at is your own choice.

Does the same formula work in Google Sheets?

Yes. The formulas on this page use only basic functions (MAX, AVERAGE, IF), which Google Sheets has too. You can type them in, or import the free.xlsx file into Google Sheets.

## More indicator formulas, with Excel sheets

[MACD formula12 EMA minus 26 EMA, a 9-period signal line and the histogram between them.](https://myalgomate.com/indicators/macd-formula) [EMA formulaA moving average that gives recent closes more weight, step by step from the first value.](https://myalgomate.com/indicators/ema-formula) [SMA & WMA formulaThe plain average of the last n closes, and the weighted version that counts recent closes more.](https://myalgomate.com/indicators/moving-average-formula) [Bollinger Bands formulaA 20-period average with bands 2 standard deviations above and below, plus %B and bandwidth.](https://myalgomate.com/indicators/bollinger-bands-formula) [Supertrend formulaATR bands around the candle's midpoint and the rules that move the line from one band to the other.](https://myalgomate.com/indicators/supertrend-formula) [VWAP formulaThe day's running total of price × volume divided by the running total of volume.](https://myalgomate.com/indicators/vwap-formula) [ATR formulaTrue range for each candle and Wilder's 14-period average of it — a measure of how much price moves.](https://myalgomate.com/indicators/atr-formula) [Stochastic formulaWhere the close sits inside the last 14 candles' high–low range (%K), and its 3-period average (%D).](https://myalgomate.com/indicators/stochastic-formula) [ADX formulaDirectional movement, +DI and −DI, DX and Wilder's 14-period ADX, column by column.](https://myalgomate.com/indicators/adx-formula) [Heikin Ashi formulaThe four formulas that turn normal candles into Heikin Ashi open, high, low and close.](https://myalgomate.com/indicators/heikin-ashi-formula) [OBV formulaA running total that adds the day's volume on an up close and subtracts it on a down close.](https://myalgomate.com/indicators/obv-formula) [Free calculators — pivot points, Camarilla, CPR, Fibonacci, position size and more →](https://myalgomate.com/tools)

## Turn your own rules into automated orders.

Already use RSI in your own rules? MyAlgoMate's [algo trading software](https://myalgomate.com/algo-trading-software) places the orders your rules call for at 150+ Indian brokers — and [TradeBridge](https://myalgomate.com/products/tradebridge) turns your own TradingView or Chartink alerts into live orders. You decide the rules; we provide the technology.

[Explore the software](https://myalgomate.com/algo-trading-software) [See products](https://myalgomate.com/products)

---
MyAlgoMate is a technology provider: its software automates the user's own trading rules. It does not give
trading tips, calls or investment advice and never promises returns. Site map for AI assistants:
https://myalgomate.com/llms.txt
