The moving average constitutes one of the simplest trading systems and is probably the most widely used tool for technical analysis. While its conceptual simplicity has attracted wide followers and perhaps indiscreet use, making a moving average (MA) system reliable and consistently profitable to any degree is an arduous exercise. The most critical task within this exercise is clearly the identification of the best moving average length to use. Over the years, I have heard many a technician, author, or trader extol the virtues of the 200-day MA, the 50-day MA, the 21-day and 13-day MA. The more exclusive writers seem to have distanced themselves from the plebeian choice of 50-day and 100-day moving average and chosen more esoteric numbers such as the 13-week MA, the 39-week MA. The more sophisticated software programmers working on technical analysis have tested a number of moving averages and have concluded that a certain moving average length is superior -- for example, 11 days beat 10. The key question is which moving average is the best choice, and why? In this article I describe an approach to finding this ideal moving average which I don't think has been published before. To understand the approach, it is essential to understand why moving averages work in the first place.

Let us do a simple exercise. Let us first draw a free chart of closing prices of a stock, with time on the x axis and prices on y axis. There are no restrictions on the shape except for the condition for any given time coordinate, there has to be only one price (i.e. you cannot have two closing prices for the stock for the same day).

Let us assume that this was the shape of the stock price movement. This price curve ("line chart") suggests that there was an opportunity to make money during the rise in the stock price from the low in March ("A") to the high in April ("B") by buying the stock and once again from "C" in April to "D" in May by short selling the stock. You probably wish you had made these trades. Probably those of us who are a bit more aggressive would also wish that we had made money by short selling at "B" and going long on the stock at the dip between "B" and "C". If only we had the prescient tool that forecasted this! Well the good news is we seem to have the right tool to achieve nearly that - the price itself!

In the chart below, I have just shifted the price plot by a few millimetres to the right on the chart and plotted that in light blue.

And there you have your trading system, that helps you to make money from very close to the peaks to very close to the troughs. The rule is whenever the red price plot cuts the blue price plot (i.e. the right shifted price plot) from below, you BUY and whenever the red price plot cuts the blue price plot from above, you SELL. Works brilliantly -- even our aggressive friends get more than their fill. They get to make money on the way down from close to "B" (the point of intersection of the two lines to be precise) to close to "1" and again from close to "1" to close to "C" and further from close to "C" to close to "2" down and from close to "2" to close to "3" up and so on. Our keen readers have probably noticed that there seems to be a confusion near point "4" if you traded the rule. The system will instruct you to sell and then buy back again, but with no significant price move. In this case it appears to be a marginal profit but there are several instances in which the net impact of this immediate reversal can be a loss (even in this case the trade around 4 could turn out to be a loss if you accounted for brokerage). These are called Whipsaws. Well, the system designer will tell you that the system does not work always but works most of the time. More specifically, the system designer claims this does not work in choppy or highly fluctuating markets but works well in trending markets. And in this case it has.

This system works on all curves and line charts that you plot, as long as you accept that it does not work in choppy markets. The following chart is an additional example with another stock. In this plot, we have highlighted the loss making ("L") and profit making ("P") trades based on the simple rule we used.

Try any plot, any shape, and this trading system works -- with the exception of highly fluctuating markets. But what about those choppy market scenarios? Let us work on them.

The best way to minimize losses is to shift the moving average further to the right. See the charts below.

With some additional right displacement we have managed to eliminate some of the losses on the right half of the chart. We have a clear trade - sell short at higher levels and buy to cover the short position at lower levels. However, on the left half, we still seem to have a wavy whipsaw. To eliminate that whipsaw as well, we have two options:

(i) We can smooth out the blue line, recognizing that some amount of the crisscross behaviour is due to the current blue line's fluctuations; OR

(ii) We smooth out the blue line while also shifting it further to the right.

Both of these charts are shown below.

Right Displaced Blue Line

Right Displaced and Smoothed Blue Line

As we can see from the charts above, all that we need to develop a successful trading system is a signal line that has a shape similar to the price curve and is shifted to the right. A moving average serves exactly that purpose.

By their very nature, moving averages smooth out interim fluctuations. Also by plotting the moving average of the preceding n trading days on the nth day, we are automatically shifting the moving average to the right. (Mathematically, the accurate day to plot the moving average would be around the n/2th day.) If the explanation so far is clear, then it is very easy to see that the choice of moving average for maximum profitability depends upon the extent of deviation from the main trend the stock witnesses from time to time. The figure below shows the deviation that I am referring to.

A simple visual optimization of the moving average so as to prevent the deviations from turning into whipsaws will produce the best possible moving average for the stock. For the more mathematical minded readers, the ideal moving average length would depend upon the average daily equivalent of the size of the deviation. The average day equivalent is calculated as:

Average size of deviation (measured over, say, last 10 identified deviations)

=

Average price move in the stock (calculated over, say, last 250 trading days)

The ideal moving average length would be two to two and a half times the average day equivalent of the deviation.

Some of the examples of this optimization are presented in charts below. An 18-day MA applies ideally to Advanced Micro Devices (AMD) stock, while a 42-day MA suits AMB Properties (AMB).

In both of these cases, the moving average has been drawn to avoid as many whipsaws as possible and keep the trader with the trend. But whipsaws are simply unavoidable during periods of sideways movement. During such periods one will see a continuous series of whipsaws. One way to avoid this would be act on the moving average signal only after the second confirmation, i.e. act only after the price line has completed a pull back to the moving average after a price crossover (shown in figure above).

So does this mean that we would be able to identify the ideal moving average length only after the event? Yes. Optimization can be done only with some history of price action. But it still does have forecasting value. Unlike methods that rely on cycles or lengths of past trends to compute the moving average length, our method uses the deviation size (which is a measure of variance from the main trend) to determine the moving average data. The size of this deviation tends to remain broadly constant for any given stock for a considerable period of time and depends upon the nature of the stock (i.e. a cyclical stock would in general have a deviation size as a larger fraction of the trend size as compared to a trending technology stock). Given this, every stock will probably require a broad optimization effort once in a while.

The next question that commonly arises is this: Does every stock have one single optimum moving average length? Clearly, no. We have illustrated the principle of a moving average and why it works on a daily chart purely as a default case. The same arguments can be applied to an hourly chart or a one-second intraday chart to optimise the moving average length for shorter term trading but it is my experience that moving average is not the most reliable intraday trading tool. I would use an optimized moving average on the daily chart for stock that I intend to hold for a three month horizon at the very least. I usually don't get perturbed with every little violation of MA line but would be very concerned if the line was emphatically broken, i.e. with a gap or on high volume and would be cautious if the MA line was flattening. Moving Averages can be terrific tools if you understood why they work and do not treat them as a holy grail or a trading system.

**Video Source:** Youtube

Loading...

More to Explore