Pages

Wednesday 17 July 2013

Calculate Moving Average


Moving average is frequently used to understand underlying trends and helps in forecasting. MACD or moving average convergence / divergence is probably the most used technical analysis tools in stock trading. It is fairly common in several businesses to use moving average of 3 month sales to understand how the trend is.
Today we will learn how you can calculate moving average and how average of latest 3 months can be calculated using excel formulas.
Calculate Moving Average using Excel Formulas

Calculate Moving Average

To calculate moving average, all you need is the good old AVERAGE excel function.
Assuming your data is in the range B1:B12,
  • Just enter this formula in the cell D3
  • =AVERAGE(B1:B3)
  • And now copy the formula from D3 to the range D4 to D12 (remember, since you are calculating moving average of 3 months, you will only get 10 values; 12-3+1)
  • That is all you need to calculate moving average.

Calculate Moving Average of Latest 3 Months Alone

Rolling Average of Last 3 Months
Lets say you need to calculate the average of last 3 months at any point of time. That means when you enter the value for the next month, the average should be automatically adjusted.
We can do that using excel formulas AVERAGE, COUNT and OFFSET
First let us take a look at the formula and then we will understand how it works.
=AVERAGE(OFFSET(B4,COUNT(B4:B33)-3,0,3,1))
So what the heck the above formula is doing anyway?
  • It is counting how many months are already entered – COUNT(B4:B33)
  • Then it is offsetting count minus 3 cells from B4 and fetching 3 cells from there – OFFSET(B4,COUNT(B4:B33)-3,0,3,1). These are nothing but the latest 3 months.
  • Finally it is passing this range to AVERAGE function to calculate the moving average of latest 3 months.

Your Home Work

Now that you have learned how to calculate moving average using Excel, here is your home work.
  • Lets say you want the number of months used to calculate moving average to be configurable in the cell E1. ie when E1 is changed from 3 to 6, the moving average table should calculate moving average for 6 months at a time. How do you write the formulas then?
Don’t look at the comments, go and figure this out for yourself. If you cant find the answer, come back here and read the comments. Go!

No comments: