Saturday, April 4, 2020

Moving Average -Part 2

The exponential moving average

Consider the data points used in the this example,
DateClosing Price
22/07/14240.6
23/07/14241.8
24/07/14242.8
25/07/14247.9
28/07/14250.2
Total1214.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 22ndJuly is as important as the data point on 28th 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 28th July) discounts all the known and unknown information. This also implies the price on 28th is more sacred than the price on 25th.
Going by this, one would like to assign weightage to data points based on the ‘newness’ of the data. Therefore the data point on 28th July gets the highest weightage, 25th July gets the next highest weightage, 24th July gets the 3rd 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.
M2-Ch13-chart2
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.

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.
M2-Ch13-chart3
Starting from left, the first opportunity to buy originated at 165, highlighted on the charts as B1@165.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 S1@187. This trade generated a profit of Rs.22 per share.
The next signal to go long came at B2@178, followed by a signal to square off at S2@182. This trade was not impressive as it resulted in a profit of just Rs.4. However the last trade, B3@165, and S3@215 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 NoBuy PriceSell PriceGain/Loss% Return
011651872213%
02178182042.2%
031652155030%
From the above table, it is very clear that the first and last trades were profitable, but the 2nd trade was not so profitable. If you inspect why this happened, it is evident that during the 1st and the 3rd trade, the stock was trending but during the 2nd 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:
  1. 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
  2. However usually one of those many trades results in a massive rally (like the B3@165 trade) leading to impressive gains
  3. It would be very difficult to segregate the big winner from the many small trades
  4. 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
  5. 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
  6. 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
  7. 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.
M2-Ch13-chart4

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.
M2-Ch13-chart5
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.
M2-Ch13-chart6
Notice, when the markets were moving sideways, MA suggested at least 3 trading signals. However the 4thtrade 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.
M2-Ch13-chart7
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:
  1. 9 day EMA with 21 day EMA – use this for short term trades ( upto few trading session)
  2. 25 day EMA with 50 day EMA – use this to identify medium term trade (upto few weeks)
  3. 50 day EMA with 100 Day EMA – use this to identify trades that lasts upto few months
  4. 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.
M2-Ch13-chart8
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.


No comments:

Post a Comment

TRADING-How to increase usability of trading style-Part 3 -"Pattern Confirmation"

So how do we confirm a pattern? There are several methods and it is down to personal preference as to how you decide to confirm your pa...