Going through the process of calculating an indicator will not only allow you to grasp the math behind it, but you'll fully appreciate what the indicator is meant to do. In this post, you'll learn how to calculate the relative strength index step by step. You'll also learn the three different ways for you to do so.
What is RSI, and what is it used for?
The relative strength index is an indicator developed by J. Welles Wilder back in the late 70s. He published this indicator in his book New Concepts in Technical Trading Systems.
RSI has a variety of purposes. Technical analysts use it for determining the strength of a trend, supplementing other indicators, spotting momentum changes, and others. You can check out this article for more RSI uses.
Making sense of RSI formula
The main component for calculating RSI is the average of up moves and down moves of a particular asset, and it measures the rate of price change using this.
What do traders look for in the RSI indicator?
Traders typically eye the 30 and 70 levels on the RSI graph, which represents the overbought and oversold conditions of prices. When the line on the graph hits 30, it indicates that price could be running out of sellers, and buyers may upturn the prevailing downtrend. Conversely, if it's at 70, the price could start falling as it runs out of buyers.
The formula for calculating the relative strength index goes like this:
RSI = 100 – 100 / ( 1 + RS )
It looks simple enough as it is, and the only thing you have to figure out is where to get the "RS" or the "relative strength."
The RS is actually the average of all price's "up" moves for a certain period of time divided by the average of all price's "down" moves for a specific period of time.
But before you go firing up price data from Yahoo Finance, you first have to know that getting the RS is not simply the average of upward and downward movements.
Here's how to calculate the RS step by step:
- Determine the number of closing prices you will need. The standard one that Wilder used was 14, so you have to use 15 days for your calculation because the first day will be left out.
- PRICE CHANGE: Subtract the latest day's closing price to the closing price of yesterday.
- Draw a table with two columns for recording UP moves and DOWN moves.
- UP MOVE: If the price is greater than zero, then the up move you will record is the same price change, and if it's less than zero (negative value), you will record zero.
- DOWN MOVE: If the price is lower than zero (negative value), you will drop the negative sign and use the absolute value, and if it's greater than zero, you will record zero.
Three ways to get the average of the Relative Strength
Now, there are three ways for you to calculate the relative strength: Simple Moving Average (SMA) Method, Exponential Moving Average (EMA) Method, and Wilder's Smoothing Method.
With the Simple Moving Average Method, it's pretty simple because all you have to do is get the average of the 14-day average of the UP moves and DOWN moves.
For the Exponential Moving Average Method, you will use a smoothing factor to put more weight on the latest closing price.
Weight: 2÷ (14 days +1)
You can watch this video to understand how to calculate the EMA using excel.
Once you have the smoothing factor calculated, you will apply it to each UP moves, and DOWN moves to get the average. Here's the formula: WEIGHT x CURRENT CLOSING PRICE + AVERAGE x (1-WEIGHT)
The Wilder Method for calculating the Relative Strength is identical to the EMA method, but the only difference is the weight, or the smoothing factor is slightly lower.
For example, the weight for the latest closing price using the Wilder Method is 0.0714285714285714 for a 14-day RSI, whereas 0.928571428571429 is the weight using the EMA Method.
So, once you've derived the RS from either one of the three methods, the next step is to divide the average of the UP moves to the average of the DOWN moves.
Average of all UP moves / Average of all DOWN moves
Next, you substitute the RS to the RSI formula: RSI = 100 – 100 / ( 1 + RS ).
The formula for RSI is straightforward, and constructing it becomes much easier if you use a spreadsheet application like Excel or Numbers so that you can record the closing prices, the up and down moves, and its averages on tables.
You can also visualize how the RSI moves if you graph how the RSI moves, just like what you would see in any charting package.
Backtest Makes Perfect
If you appreciated how to calculate the RSI, then the next step is to learn how it applies on the chart. Backtesting is one of the cost-effective way for you to understand RSI's performance based on past price data and we wrote a whole article about it. You can click the link below to learn more.