We have all learnt about averages in school, moving average is just an extension of that. Moving averages are trend indicators and are frequently used due to their simplicity and effectiveness. Before we learn moving averages, let us have a quick recap on how averages are calculated.

Assume 5 people are sitting on a nice sunny beach enjoying a nice chilled bottled beverage. The sun is so bright and nice that each one of them end up drinking several bottles of the beverage. Assume the final count to be something like this:

Sl No | Person | No of Bottles |
---|---|---|

01 | A | 07 |

02 | B | 05 |

03 | C | 06 |

04 | D | 03 |

05 | E | 08 |

Total # of bottles consumed | 29 |

Assume a 6^{th} person walks in to find out 29 bottles of beverages lying around them. He can quickly get a sense of ‘roughly’ how many bottles each of them consumed by dividing **[the total number of bottles]** by **[total number of people]**.

In this case it would be:

=29/5

=5.8 bottles per head.

So, the average in this case tells us roughly how many bottles each person had consumed. Obviously there would be few of them who had consumed above and below the average. For example, Person E drank 8 bottles of beverage, which is way above the average of 5.8 bottles. Likewise, person D drank just 3 bottles of beverage, which is way below the average of 5.8 bottles. Therefore average is just an estimate and one cannot expect it to be accurate.

Extending the concept to stocks, here are the closing prices of ITC Limited for the last 5 trading sessions. The last 5 day average close would be calculated as follows:

Date | Closing Price |
---|---|

14/07/14 | 344.95 |

15/07/14 | 342.35 |

16/07/14 | 344.20 |

17/07/14 | 344.25 |

18/07/14 | 344.0 |

Total | 1719.75 |

= 1719.75 / 5

= 343.95

Hence the average closing price of ITC over the last 5 trading sessions is 343.95.

## 13.1 – The ‘moving’ average (also called the simple moving average)

Consider a situation where you want to calculate the average closing price of Marico Limited for the **latest** **5 days**. The data is as follows:

Date | Closing Price |
---|---|

21/07/14 | 239.2 |

22/07/14 | 240.6 |

23/07/14 | 241.8 |

24/07/14 | 242.8 |

25/07/14 | 247.9 |

Total | 1212.3 |

= 1212.3/ 5

= 242.5

Hence the average closing price of Marico over the last 5 trading sessions is 242.5

Moving forward, the next day i.e 28^{th} July (26^{th} and 27^{th} were Saturday and Sunday respectively) we have a new data point. This implies now the ‘new’ latest 5 days would be 22^{nd}, 23^{rd}, 24^{th}, 25^{th} and 28^{th}. We will drop the data point belonging to the 21st as our objective is to calculate the latest 5 day average.

Date | Closing Price |
---|---|

22/07/14 | 240.6 |

23/07/14 | 241.8 |

24/07/14 | 242.8 |

25/07/14 | 247.9 |

28/07/14 | 250.2 |

Total | 1223.3 |

= 1223.3/ 5

= 244.66

Hence the average closing price of Marico over the last 5 trading sessions is 244.66

As you can see, we have included the latest data (28^{th} July), and discarded the oldest data (21^{st} July) to calculate the 5 day average. On 29^{th}, we would include 29^{th} data and exclude 22^{nd} data, on 30^{th} we would include 30^{th} data point but eliminate 23^{rd} data, so on and so forth.

So essentially, we are moving to the latest data point and discarding the oldest to calculate the latest 5 day average. Hence the name “moving” average!

In the above example, the calculation of moving average is based on the closing prices. Sometimes, moving averages are also calculated using other parameters such as high, low, and open. However the closing prices are used mostly by the traders and investors as it reflects the price at which the market finally settles down.

Moving averages can be calculated for any time frame, from minutes, hours to years. Any time frame can be selected from the charting software based of your requirements.

For those of you familiar with excel, here is a screenshot of how moving averages are calculated on MS Excel. Notice how the cell reference moves in the average formula, eliminating the oldest to include the latest data points.

Cell Ref | Date | Close Price | 5 Day Average | Average Formula |
---|---|---|---|---|

D3 | 1-Jan-14 | 1287.7 | ||

D4 | 2-Jan-14 | 1279.25 | ||

D5 | 3-Jan-14 | 1258.95 | ||

D6 | 6-Jan-14 | 1249.7 | ||

D7 | 7-Jan-14 | 1242.4 | ||

D8 | 8-Jan-14 | 1268.75 | 1263.6 | =AVERAGE(D3:D7) |

D9 | 9-Jan-14 | 1231.2 | 1259.81 | =AVERAGE(D4:D8) |

D10 | 10-Jan-14 | 1201.75 | 1250.2 | =AVERAGE(D5:D9) |

D11 | 13-Jan-14 | 1159.2 | 1238.76 | =AVERAGE(D6:D10) |

D12 | 14-Jan-14 | 1157.25 | 1220.66 | =AVERAGE(D7:D11) |

D13 | 15-Jan-14 | 1141.35 | 1203.63 | =AVERAGE(D8:D12) |

D14 | 16-Jan-14 | 1152.5 | 1178.15 | =AVERAGE(D9:D13) |

D15 | 17-Jan-14 | 1139.6 | 1162.41 | =AVERAGE(D10:D14) |

D16 | 20-Jan-14 | 1140.6 | 1149.98 | =AVERAGE(D11:D15) |

D17 | 21-Jan-14 | 1166.35 | 1146.26 | =AVERAGE(D12:D16) |

D18 | 22-Jan-14 | 1165.4 | 1148.08 | =AVERAGE(D13:D17) |

D19 | 23-Jan-14 | 1168.25 | 1152.89 | =AVERAGE(D14:D18) |

As it is evident, the moving average changes as and when the closing price changes. A moving average as calculated above is called a ‘Simple Moving Average’ (SMA). Since we are calculating it as per the latest 5 days of data it is called referred to as 5 Day SMA.

The averages for the 5 day (or it could be anything like 5, 10, 50, 100, 200 days) are then joined to form a smooth curving line known as the moving average line, and it continues to move as the time progresses.

In the chart shown below, I have overlaid a 5 day SMA over ACC’s candlestick graph.

So what does a moving average indicate and how does one use it? Well, there are many applications of moving average and shortly I will introduce a simple trading system based on moving averages. But before that, let us learn about the Exponential Moving Average.

## 13.2 – The exponential moving average

Consider the data points used in the this example,

Date | Closing Price |
---|---|

22/07/14 | 240.6 |

23/07/14 | 241.8 |

24/07/14 | 242.8 |

25/07/14 | 247.9 |

28/07/14 | 250.2 |

Total | 1214.5 |

When one calculates the average across these numbers there is an unstated assumption. We are essentially giving each data point equal importance. Meaning, we are assuming that the data point on 22^{nd} July is as important as the data point on 28^{th} July. However, when it comes to markets, this may not always be true

Remember the basic assumption of technical analysis – markets discount everything. This means the latest price that you see (on 28^{th} July) discounts all the known and unknown information. This also implies the price on 28^{th} is more sacred than the price on 25^{th}.

Going by this, one would like to assign weightage to data points based on the ‘newness’ of the data. Therefore the data point on 28^{th} July gets the highest weightage, 25^{th} July gets the next highest weightage, 24^{th} July gets the 3^{rd} highest, and so on.

By doing so, I have essentially scaled the data points according to its newness – the latest data point gets the maximum attention and the oldest data point gets the least attention.

The average calculated on this scaled set of numbers gives us the Exponential Moving Average (EMA). I deliberately skipped the EMA calculation part, simply because most of the technical analysis software lets us drag and drop the EMA on prices. Hence we will focus on EMA’s application as opposed to its calculation.

Here is a chart of Cipla Ltd. I have plotted a 50 day SMA (black) and a 50 day EMA (red) on Cipla’s closing prices. Though both SMA and EMA are for a 50 day period, you can notice that the EMA is more reactive to the prices and hence it sticks closer to the price.

The reason why EMA is quicker to react to the current market price is because EMA gives more importance to the most recent data points. This helps the trader to take quicker trading decisions. Hence for this reason, traders prefer the use of the EMA over the SMA.

## 13.3 – A simple application of moving average

The moving average can be used to identify buying and selling opportunities with its own merit. When the stock price trades above its average price, it means the traders are willing to buy the stock at a price higher than its average price. This means the traders are optimistic about the stock price going higher. Therefore one should look at buying opportunities.

Likewise, when the stock price trades below its average price, it means the traders are willing to sell the stock at a price lesser than its average price. This means the traders are pessimistic about the stock price movement. Therefore one should look at selling opportunities.

We can develop a simple trading system based on these conclusions. A trading system can be defined as a set of rules that help you identify entry and exit points.

We will now try and define one such trading system based on a 50 day exponential moving average. Remember a good trading system gives you a signal to enter a trade and a signal to close out the trade. We can define the moving average trading system with the following rules:

**Rule 1)** Buy (go long) when the current market price turns greater than the 50 day EMA. Once you go long, you should stay invested till the necessary sell condition is satisfied

**Rule 2)** Exit the long position (square off) when the current market price turns lesser than the 50 day EMA

Here is a chart that shows the application of the trading system on Ambuja cements. The black line on the price chart is the 50 day exponential moving average.

Starting from left, the first opportunity to buy originated at 165, highlighted on the charts as [email protected] Notice, at point B1, the stock price moved to a point higher than its 50 day EMA. Hence as per the trading system rule, we initiate a fresh long position.

Going by the trading system, we stay invested till we get an exit signal, which we eventually got at 187, marked as [email protected] This trade generated a profit of Rs.22 per share.

The next signal to go long came at [email protected], followed by a signal to square off at [email protected] This trade was not impressive as it resulted in a profit of just Rs.4. However the last trade, [email protected], and [email protected] was quite impressive resulting in a profit of Rs.50.

Here is a quick summary of these trades based on the trading system fared:

Sl No | Buy Price | Sell Price | Gain/Loss | % Return |
---|---|---|---|---|

01 | 165 | 187 | 22 | 13% |

02 | 178 | 182 | 04 | 2.2% |

03 | 165 | 215 | 50 | 30% |

From the above table, it is very clear that the first and last trades were profitable, but the 2^{nd} trade was not so profitable. If you inspect why this happened, it is evident that during the 1^{st} and the 3^{rd} trade, the stock was trending but during the 2^{nd} trade the stock moved sideways.

This leads us to a very important conclusion about the moving averages. Moving averages works brilliantly when there is a trend and fails to perform when the stock moves sideways. This basically means the ‘Moving average’ in its simplest form is a trend following system.

From my own personal experience of trading based on moving averages, I have noticed a few important characteristics:

- Moving averages gives you many trading signals (buy and sell) during a sideways market. Most of these signals result in marginal profits, if not for losses
- However usually one of those many trades results in a massive rally (like the [email protected] trade) leading to impressive gains
- It would be very difficult to segregate the big winner from the many small trades
- Hence the trader should not be selective in terms of selecting signals that moving average system suggest. In fact the trader should trade all the trades that the system suggests
- Remember the losses are minimum in a moving average system, but that 1 big trade is good enough to compensate all the losses and can give you sufficient profits
- The profit making trade ensures you are in the trend as long as the trend lasts. Sometime even upto several months. For this reason, MA can be used as a proxy for identifying long term investment ideas
- The key to MA trading system is to take all the trades and not be judgmental about the signals being generated by the system.

Here is another example of BPCL, where the MA system suggested multiple trades during the sideways market, however none of them were really profitable. However, the last trade resulted in a 67% profit in about 5 months.

## 13.4 – Moving average crossover system

As its evident now the problem with the plain vanilla moving average system is that it generates far too many trading signals in a sideway market. A moving average crossover system is an improvisation over the plain vanilla moving average system. It helps the trader to take fewer trades in a sideways market.

In a MA crossover system, instead of the usual single moving average, the trader combines two moving averages. This is usually referred to as ‘smoothing’.

A typical example of this would be to combine a 50 day EMA, with a 100 day EMA. The shorter moving average (50 days in this case) is also referred to as the faster moving average. The longer moving average (100 days moving average) is referred to as the slower moving average.

The shorter moving average takes lesser number of data points to calculate the average and hence it tends to stick closer to the current market price, and therefore reacts more quickly. A longer moving average takes more number of data points to calculate the average and hence it tends to stay away from the current market price. Hence the reactions are slower.

Here is the chart of Bank of Baroda, showing you how the two moving averages stack up when loaded on a chart.

As you can see, the black 50 day EMA line is closer to the current market price (as it reacts faster) when compared to the pink 100 day EMA (as its reacts slower).

Traders have modified the plain vanilla MA system with the crossover system to smoothen out the entry and exit points. In the process, the trader gets far fewer signals, but the chances of the trade being profitable are quite high.

The entry and exit rules for the crossover system is as stated below:

**Rule 1)** – Buy (fresh long) when the short term moving averages turns greater than the long term moving average. Stay in the trade as long as this condition is satisfied

**Rule 2)** – Exit the long position (square off) when the short term moving average turns lesser than the longer term moving average

Let us apply the MA crossover system to the same BPCL example that we looked at. For ease of comparison, I have reproduced the BPCL’s chart with a single 50 day MA.

Notice, when the markets were moving sideways, MA suggested at least 3 trading signals. However the 4^{th} trade was the winner which resulted in 67% profit.

The chart shown below shows the application of a MA crossover system with 50 and 100 day EMA.

The black line plots the 50 day moving average and the pink line plots the 100 day moving average. As per the cross over rule, the signal to go long originates when the 50 day moving average (short term MA) crosses over the 100 day moving average (long term MA). The crossover point has been highlighted with an arrow. Please do notice how the crossover system keeps the trader away from the 3 unprofitable trades. This is the biggest advantage of a cross over system.

A trader can use any combination to create a MA cross over system. Some of the popular combinations for a swing trader would be:

- 9 day EMA with 21 day EMA – use this for short term trades ( upto few trading session)
- 25 day EMA with 50 day EMA – use this to identify medium term trade (upto few weeks)
- 50 day EMA with 100 Day EMA – use this to identify trades that lasts upto few months
- 100 day EMA with 200 day EMA – use this to identify long term trades (investment opportunities), some of them can even last for over a year or more.

Remember, longer the time frame the lesser the number of trading signals.

Here is an example of a 25 x 50 EMA crossover. There are three trading signals that qualify under the crossover rule.

Needless to say, the MA crossover system can also be applied for intraday trading. For instance one could use the 15 x 30 minutes crossover to identify intraday opportunities. A more aggressive trader could use 5 x 10 minute crossover.

You may have heard this popular saying in the markets – “The trend is you friend”. Well, the moving averages help you identify this friend.

Remember, MA is a trend following system – as long as there is a trend, the moving averages works brilliantly. It does not matter which time frame you use or which cross over combination you use.

### Key takeaways from this chapter

- A standard average calculation is a quick approximation of a series of numbers
- In a average calculation where the latest data is included, and the oldest is excluded is called a Moving Average
- The simple moving average (SMA) gives equal weightage to all data points in the series
- An exponential moving average (EMA) scales the data according to its newness. Recent data gets the maximum weightage and the oldest gets the least weightage
- For all practical purposes, use an EMA as opposed to SMA. This is because the EMA gives more weightage to the most recent data points
- The outlook is bullish when the current market price is greater than the EMA. The outlook turns bearish when the current market price turns lesser than the EMA
- In a non trending market, moving averages may result in whipsaws thereby causing frequent losses. To overcome this a EMA crossover system is adopted
- In a typical crossover system, the price chart is over laid with two EMAs. The shorter EMA is faster to react, while the longer EMA is slower to react
- The outlook turns bullish when the faster EMA crosses and is above the slower EMA. Hence one should look at buying the stock. The trade lasts upto a point where the faster EMA starts going below the slower EMA
- The longer the time frame one chooses for a crossover system, the lesser the trading signals.

Hello Sir,

First of all thank you so much for what you guys are doing . 🙂

I have a doubt.Can i select 9×21 crossover system on 5min. chart for intraday opportunities?

Thanks 🙂

Yes, you can use a 9 x 21 on a 5 minute candle.

I have a one question regarding use MA crossover system how its work and how we can find call . in both line.. for intraday.

Sure, please do ask the same.

Can you explain how to draw 15 * 30 mins crossover ? I am not clear

You will first need to decide on the number of candles for which you want the MA. Then, you can open a 15 min chart and add 2 moving averages with the period ‘X’ and ‘X*2’

Say you want to plot for 100 candles. Choose 100 for 1st MA and 200 for 2nd MA. That will give you a 15 min * 30 min crossover

The period you have mentioned is in days. How can we select no of candles in 15*30 minutes chart and how to plot chat for 15*30minutes. Please tell clearly as I am new to using the tools.

Sir, as you rightly mentioned, I’ve also noticed that MA’s perform whenever the market’s in a trend. However, I’ve observed this quite often and feel that the duration of the EMA crossovers need to be backtested on a scrip across its historical data points to arrive at the best possible trade entry/exit positions. For ex: I’ve found that a 5×20 EMA crossover on 5-min Heikin Ashi candlestick pattern works pretty well for HINDALCO.

Agree, Rajiv. It is always good to trade with deeper insights.

Does it work for Intraday trade?

Yup, it does.

Sir can you tell me in last chart there are two moving averages .my ques. Is

Why those lines are getting up and down with each other.?

I’d suggest you read the chapter again, Sahil. Its explained well there.

how to avoid whip saws in the cross over systems

You can avoid whip saws to some extent by using a higher value moving average.

how to avoid whipsaw of higher value cross over , if you continue this there won’t

be any trade to take , can you elaborate on your answer. if you go on choosing higher value where is the end .

Agreed. The thing is, if you choose a higher MA cross over, whipsaws are reduced to a great extent. However avoiding whipsaws while using MA system is not possible…especially when the markets are moving sideways. So between the two i.e lower MA and higher MA, I would suggest a higher value MA crossover as it tends to reduces the whipsaws.

Karthik, Can you enlighten me on whipsaws. I’m new to that word

Whipsaw is a term used when the market fluctuates between two price points for a prolonged period. For example if a stock is trading between 950 and 975 for the longest period then both bulls and bears will find it difficult to make meaningful money. This is because the stock is fluctuating between two price levels (which are close to each other)…and usually the fluctuations are rapid. This is called “Whipsaws”.

Thanks Karthik for the explanation of whipsaw, I knew what it meant, but was not sure why this happens. One idea that i had was whipsaw was a result of some negative news in the market at that time.

Cheers, happy to clear that doubt for you 🙂

🙂

If there are whipsaws, then doesn’t it mean that there is no trend and we shouldn’t use MA Crossover in no-trend market.

Yes, MAs does not really give you great results when the markets whipsaws.

average is average whats higher and lower in it??

Moving average – changes as new data flows in.

but suppose if i wanna take average of last 5 sessions (1st day, 2nd day, 3rd day, 4th day, 5th day)and its 1000 then whats the higher value in this . the only value we have is 1000.whats the high average and low average we have only 1 average and ie 1000

i hope i made my que clear to u

What if the data on the 5th day is skewed and your average jumps to 1000 from the usual 650?

Which crossover system and candle chart are preferable for intra day trading in MCX bullion market. Thank you.

Irrespective of the asset class for intra day trading I would advice 10 or 15 mins charts..as longer the time duration is longer, the more reliable is the trading signal. Going by the same logic, I would advice you to use slightly longer term MA cross over for better accuracy.

Thanks Sir,

Thanks for your valuable guidance pl tell me in 10/15 mint chart or in intra day trading which indicator are best to do technical analysis,

I am new here in this field and using Zerodha as my preferred broker ☺

Thanks in advance!

I personally prefer the moving averages, they are simple and helps in most cases.

Karthik Can you Please explain something about divergence

Hi nitesh,

A stock is said to be in divergence when the momentum forms lower peaks while the stock is forming higher peaks….

Reverse is true for bear markets.. Hav a look at the following picture for a better understanding..

Thanks JAGADEESH

Jagadeesh has posted a quick background information. I will try and elaborate on it sometime soon…but I personally don’t like to look at divergence and convergence, hence have not covered it in Varsity.

Hi Karthik

How to Trade the Below Situation when no cross overs happening and the RSI and Stoacstics not in Favor of short trade

From what I can see from the chart, clearly the trade is in favor of a long position. This is because the MA cross over has already happened and it seems like a trend is being formed. I would wait for a retracement on low volumes to enter a position. Ofcoure, the other checklist items should also comply.