Moving Averages
Moving average is a widely used technical indicator of stock prices that helps to smooth out the volatility in the price action by filtering out the noise from random price fluctuations. A moving average is a trendfollow lagging indicator as it is calculated taking past data into consideration. As its name suggests, a moving average is an average that moves as old values are dropped out as new values become available. Moving averages can be employed to identify the current trend in a script.
Types of moving averages
There are 3 types of moving averages
a) Simple moving average (SMA)
It is obtained by computing the simple average of price data over a defined period of time. In general, we compute the simple moving average based on the closing price of the security as it is considered to have more significance as compared to the rest of price points (Namely open/high/low price for the day). Thus, a 5day SMA is calculated by adding the closing price of 5 days and dividing this sum by the total number of days (in this case, five).
For example, the 5 days SMA of ITC is calculated as follows:
While calculating the Moving Average after the close of the trading session on July 7, 2017, we can compute the SMA value by taking the closing price of the last 5 trading session, including July 7, 2017, and dividing the same by 5. At close of the next trading session on July 10, 2017, SMA is calculated by excluding the Closing Price of July 3, 2017 by adding the new data point. (Closing Price of July 10, 2017).
As illustrated in the example below, prices gradually decreases from 342.5 to 328.85 over a period of eight days in the same timeframe the 5 Period SMA decreases from 336.44 to 332.79, indicating a lag associated with the Moving Averages. Hence, larger the time period, larger is the lag.
Date  Close Price  5 Period SMA 
03Jul17  342.5 

04Jul17  337.25 

05Jul17  331.05 

06Jul17  337.10 

07Jul17  334.30  336.44 
10Jul17  333.30  334.60 
11Jul17  330.40  333.23 
12Jul17  328.85  332.89 
7TH July SMA = 336.44= (342.50+337.25+331.05+337.10+334.30)
5
10th July SMA =334.6= (337.25+331.05+337.10+334.30+333.30)
5
11th July SMA= 333.23= (331.05+337.10+334.30+333.30+330.40)
5
12th July WMA= 332.89= (337.10+334.30+333.30+330.40+328.85)
5
b) Weighted moving average (WMA)
Weighted moving average moves a step ahead from simple moving average. Here, we assign a weight to each value, with a bigger weight assigned to the most recent data points as they are more relevant than historical data points. The sum of weights should add up to 1 (or 100%). As new data points are added, the new weights will align accordingly. In contrast, in simple moving average, each value is assigned the same weight. Ideally, traders calculate WMA on the basis of closing price.
The weighted moving average is calculated by multiplying the given price by its assigned weight and then dividing the sum by total number of days. The weights assigned are subjective in nature, and it is based on the discretion of the trader. Because of its calculation methodology, WMA will follow prices more closely than a corresponding SMA. The WMA reduces the lag effect to an extent.
 Close Price  Weights  WMA 
03Jul17  342.5  0.07 

04Jul17  337.25  0.13 

05Jul17  331.05  0.20 

06Jul17  337.10  0.27 

07Jul17  334.30  0.33  335.34 
10Jul17  333.30 
 334.29 
11Jul17  330.40 
 332.89 
12Jul17  328.85 
 331.43 
7TH July WMA = 335.34= (342.50*0.07+337.25*0.13+331.05*0.20+337.10*0.27+334.3*0.33)
5
10th July WMA =334.29= (337.25*0.07+331.05*0.13+337.10*0.20+334.3*0.27+333.3*0.33)
5
11th July WMA= 332.89= (331.05*0.07+337.10*0.13+334.30*0.20+333.3*0.27+330.4*0.33)
5
12th July WMA= 331.43= (337.1*0.07+334.30*0.13+333.30*0.20+330.4*0.27+328.85*0.33)
5
C) Exponential moving average (EMA)
Exponential moving average differs from the simple and weighted moving average as an EMA is calculated by taking all the historical data points since the inception of the stock. Ideally, to calculate 100% accurate EMA, we should make use of all the closing prices right from the time of the listing of stock.
Calculation of the EMA is a 3 step process
Step 1: Since it is not practical to calculate historical data right from the inception of the stock, we use the SMA value as the initial EMA value. So, a simple moving average is used as the previous period’s EMA in the first calculation.
Step 2: We calculate the weighting multiplier by dividing 2 by the sum of total periods and 1.
Step 3: We subtract the EMA of the previous day from the current closing price, and multiply this number by the multiplier. We then add this product with its previous period EMA to find out the final EMA value.
Therefore, the current EMA value will change depending on how much past data we use in our EMA calculation. The more data points we use, the more accurate our EMA will be. The goal is to maximize accuracy while minimizing calculation time.
Initial EMA value = 5period SMA
Weighting Multiplier= (2 / (Time periods + 1)) = (2 / (5 + 1) ) = 0.3333 (33.33%)
EMA= {Close – EMA of previous day} x multiplier + EMA (previous day).
A 5period EMA applies a 33.33% weighting to the most recent prices. A 10period EMA has a weighting multiplier of 18.18%. The shorter the time period, larger the weighting multiplier will be. We notice that as the time period doubles, the weighting multiplier drops ~50%.
Date  Close Price  5 Period SMA  Weighting factor  5 Period EMA 
03Jul17  342.5 



04Jul17  337.25 



05Jul17  331.05 



06Jul17  337.10 



07Jul17  334.30  336.44 
 336.44 
10Jul17  333.30  334.60  0.3333  335.39 
11Jul17  330.40  333.23  0.3333  333.73 
12Jul17  328.85  332.79  0.3333  332.10 
7TH July EMA = 5 Period SMA= 336.44
10THJuly EMA = 335.39= (333.30336.44) x0.33 + 336.44
11THJuly EMA = 333.73= (330.40335.39) x0.33 + 335.39
12THJuly EMA =332.10= (328.85 333.72) x0.33 +333.72
Comparison of the 3 moving averages
As we see by comparing the computation methodology of the 3 moving averages, different values are generated. EMA is most commonly used by traders.
Moving Averages  SMA  WMA  EMA 
Advantages  1)Smoothened Average  1)Reduction in price lag, so can be implemented for short term trading  1)Reduction in price lag, hence can be used for short term trading 
Disadvantages  1)Has maximum price lag  1) Omission of previous data points leading to all price data not made use of  1)Chance of whipsaw 
Moving Average Value comparison – The following table represents a comparison between the different values of the 3 types of Moving Averages over the same period of time
Date  Close Price  5 Period SMA 