# Moving Average Calculation

Moving averages are of particular significance for traders. They are straightforward, yet very effective tools to gauge buying and selling points in a chart. Although you can directly use it on the chart to gain a better understanding of how it functions let’s understand the moving average calculation.

**How to Calculate Moving Average?**

As you know the moving averages use past price data to deduce market trends so it becomes essential to understand how different moving averages behave when price data is fed to them.

But **is moving average a good indicator**? Well for this let’s understand how to calculate the value of both the indicators.

Following are the ways to calculate moving averages i.e Simple Moving Average and Exponential Moving Average.

**Simple Moving Average Calculation **

It is one of the simplest moving averages to calculate. A simple moving average is calculated by dividing the opening, closing, high or low prices (you can choose any one of them for calculation) of a stock over a specific period say 5 days, 20 days, or 50 days.

Let’s show you an example of how it works. To better understand, we have taken the 5 days closing price of HDFC Bank between June 28 and July 4th, 2022.

Closing Price Data | |

Date | Closing Price |

July 4th | ₹1355.65 |

July 1st | ₹1353.75 |

June 30th | ₹1348.00 |

June 29th | ₹1343.95 |

June 28th | ₹1345.90 |

Sum Total | ₹6747.25 |

**SMA Formula **

Now to calculate SMA, you simply have to use the average formula as under:

SMA = P1 + P2 + P3 + P4 + P5 / N

where, N= Number of Days

Putting the values in the formula, ₹6747.25/5

Simple Moving Average = ₹1349.45

In this way, you can calculate SMA for any number of months, weeks, days, hours or minutes.

**EMA Calculation**

As you know exponential moving averages (EMA) are faster moving averages so short-term traders prefer them.

Exponential moving averages are used by traders to establish the current trend.

EMA does so by tracking the price line. In simpler terms when the stock price line on a chart moves above the exponential moving average line from below, it will generate a buy signal.

In case the price line moves below the EMA line from above, it will be a sell signal for traders.

However, the Exponential Moving Average is highly reactive to price changes which is why it needs to be traded carefully. Even a simple reaction can look like an upcoming trend, generating an incorrect trading decision.

Now let’s come to the point i.e calculation of the Exponential moving average.

As you know EMA gives us the flexibility in forming trading strategies with high, low, open, or close prices of security so you can choose any one of four of them.

Also, you can choose any period length ranging from minutes to days to calculate an exponential moving average.

Let us show you how to calculate the exponential moving average with an example.

Here we have taken the 5 days closing price of Tata motors from April 28th to May 5.

Closing Price Data | |

Date | Closing Price |

May 5th | ₹426.30 |

May 4th | ₹423.50 |

May 2nd | ₹432.85 |

April 29th | ₹437.60 |

April 28th | ₹436.05 |

Sum Total | ₹2156.30 |

**EMA Formula**

Now to calculate EMA, first, you have to find the SMA value of the defined period.

SMA = P1 + P2 + P3 + P4 + P5 / N = ₹2156.30 /5

SMA = ₹431.26

Now, using the EMA formula:

**EMA = K*(Current Price – Previous EMA) + Previous EMA**

**Where:**

- K is the weighting factor for EMA
- K = 2 / (n+1), here ‘n’ is the number of selected time periods
- Previous EMA = Previous day EMA or if calculating for the first time, SMA is used in the place of previous EMA

With this formula, the EMA would be ₹**429.62**

Now, you can see that the EMA of the closing price is ₹429.62 which is more close to the current price of the stock (price on May 5th) while the SMA is ₹431.26, therefore, it reflects that EMA follows the price more closely as compared to SMA.

That is why EMA is used for short-term trade rather than, SMA which is more feasible for long-term trades. You can gain a better understanding of the differences between the two in a complete review of **SMA vs EMA**.

**Conclusion**

This is how you can calculate EMA or SMA for a specific period. Seems to be difficult, well you can select these indicators on the chart and gain an idea of the bullish or bearish trend in the market.

Hope you got the idea of the calculation of moving averages. If you want to learn more about moving averages, and their use in trading you can subscribe to our Stock Pathshala course.

In case you’d like us to call you back to explain more about stock market learning, just leave your contact info below:

#### Start Learning through Free & Pro Stock Market Courses!

Install Stock Pathsahla and Get Exclusive 20% off on all subscriptions.Use Coupon Code SPWEB20