• Features
  • Using Moving Averages in a Systematic Trading Strategy

    by Wayne A. Thorp, CFA

    Using Moving Averages In A Systematic Trading Strategy Splash image

    In the August issue of the AAII Journal, I covered one of the more basic technical indicators: moving averages, including how you could construct simple, weighted, and exponential moving averages, as well as some practical applications.

    This article moves a step forward and examines how you can use moving averages as part of a systematic trading strategy. First, it will look at one- and two-line moving average systems and how you can use them to generate buy and sell signals, and then, it will touch upon system optimization and how traders use it to improve the profitability of a trading system.

    one-line moving average systems

    Although this technique is not as popular as using multiple moving averages, it will allow you to understand the concepts behind such systems without being confused by several moving averages.

    When you view a single moving average in unison with a price chart, buy signals are generated when the price rises above the moving average. In a broad context, the movement of the price above a moving average is considered a bullish signal. Similarly, when the price falls below the moving average line, a sell or sell-short signal is generated. In this case, the price falling below the moving average is viewed as being bearish. Keep in mind too that the longer the time period you use to construct the moving average, the more significant the signal is.

    Figure 1 illustrates a one-line moving average trading system. Here you see the price behavior of AFLAC between October 1998 and June 1999. The up and down arrows on the chart indicate where the price broke above or below the 50-day simple moving average. The up arrows indicate buy signals while the down arrows denote sell signals. Using strictly long positions—buying when the price rises above the 50-day moving average and selling when the price falls below the moving average—the three round-trip trades (buy and sell) would have yielded a total gain of over 57%. Be aware that this figure excludes commissions and does not take into account slippage. Also, it is important to point out that all of these examples assume that trades are entered and exited at the point when the moving average is “violated.” This does not mean that a trade could have been placed at that price—an issue that can have a significant impact on the return of a trade and the system as a whole.

    While the AFLAC example shows that a single moving average system can be profitable, using a single moving average does have its pitfalls—whipsaws. A whipsaw occurs when a signal is generated (typically a buy), only to have the price make a sudden reversal (to the downside). By the time a sell signal is generated, the transaction results in a loss. Figure 2 illustrates a whipsaw. Here we have a price chart for Indiana Energy from April until May 1999 as well as a 50-day simple moving average. On April 12, the price broke above the moving average at $19.968 and closed at $20.75. Over a week later, on April 20, the price fell below the moving average at $19.826 and closed at $19.687. If you had followed the buy signal when the price rose above the moving average and sold when the price fell below the moving average, this trade would have resulted in a slight loss (excluding commissions, slippage, etc.). If commissions were included, the percentage loss would have been even more.

    If you trade over a longer time period, whipsaws could have a noticeable impact on your profits. There are ways to safeguard yourself—such as lengthening the time period over which you calculate the moving average. In doing so, the average becomes less responsive to sudden price movements and will help eliminate whipsaws. While such tactics tend to lower the occurrence of “bad” trades, you also tend to lower the profits gleaned from “good” trades. If you lengthen the time period of the moving average, the average will react more slowly to price changes. As a result, you will be entering trades at a later time, thus perhaps missing some of the upward movement. Furthermore, you will tend to exit trades later and may sacrifice some of your gains. These are some of the trade-offs one faces when optimizing any trading system.

    two-line systems

    By adding additional moving averages to a trading system, you lower the risk of whipsaws or other false trading signals. When using multiple moving averages, buy and sell signals are generated at points called “crossovers”—points where two averages cross one another. The concept is similar to that used with one-line moving average systems, but with multiple averages you are watching for the lines to cross one another rather than the actual price.

    The Adobe Systems chart in Figure 3 shows you a two-line moving average system. Signals with this system are generated when the 20-day simple moving average line crosses over the 50-day simple moving average line and vice versa. Specifically, when the 20-day line moves above the 50-day line, a buy signal is generated. Similarly, when the 20-day line falls below the 50-day, this is a short sell signal. During the time period from August 1998 until July 28, 1999, this system generated three round-trip trades and one open trade. Using only long positions, and excluding commissions and slippage, the three round-trip trades generated a gain of 33.1% or 11% per trade. The last trade, which has been open since March 23, 1999, has generated a 72.5% gain through July 28—bringing the entire system’s gain to 105.6%.

    Looking at the trading signals generated by the system for Adobe, you can see that this, like any other trading system, is not foolproof. The second trade, over the course of three months, generated a loss of 4%. However, this should give you a general idea of how you could use such a system.

    In the attempts to make your system foolproof, you can make your system more restrictive. In the case of a two-line moving average system, you can limit your buying at a crossover to only those times when both lines are in an upward trend. While following such strategies may eliminate losing trades, you again run the risk of eliminating profitable trades as well.

    Of course, a trading system need not be limited to one- or two-line moving averages. If you wish, you can keep adding moving averages to your system. Some investors may use three or five moving averages in their trading strategy.

    No matter how many moving averages your system may contain, the basic buy and sell principles are the same—the crossing of moving averages generates a trading signal. When a shorter-term average crosses above a longer-term average, this is a bullish sign, and when the shorter-term averages cross below a longer-term line, this is a bearish signal.

    “Optimizing” Your System

    You can see that by changing certain variables such as the period length and price input, you can alter the performance of your trading system. Such manipulation of a trading system is called system optimization. Many of the more advanced technical analysis software packages on the market today that offer either pre-installed trading systems or the ability for you to create your own also allow for system optimization.

    SPECIAL OFFER: Get AAII membership FREE for 30 days!
    Get full access to AAII.com, including our market-beating Model Stock Portfolio, currently outperforming the S&P 500 by 2-to-1. Plus 60 stock screens based on the winning strategies of legendary investors like Warren Start your trial now and get immediate access to our market-beating Model Stock Portfolio (beating the S&P 500 2-to-1) plus 60 stock screens based on the strategies of legendary investors like Warren Buffett and Benjamin Graham. PLUS get unbiased investor education with our award-winning AAII Journal, our comprehensive ETF Guide and more – FREE for 30 days


    There are numerous ways you can optimize systems, such as those discussed earlier. We have discussed the fact that altering the period of the average will influence the signals it generates: Decreasing the length of the period makes the average more sensitive to price changes but increases the possibility of receiving incorrect signals; lengthening the period generally reduces the number of incorrect signals but also slows the average’s response time to a change in price.

    If you wish to further reduce the risk of receiving incorrect signals, you can place greater demands on the closing price and the price penetration. Some traders require that the entire range of the price—open, high, low, and close—be outside the average before they act on a signal. You can also require that the price be either above or below the average by a certain dollar amount or percentage before buying or selling.

    Lastly, you can place a time restriction on a price penetration as a confirmation of a change in the current trend. While the trading systems outlined earlier signaled buy or sell based on whether the average was penetrated by a closing day price, you can insist on waiting a day or two after the breaking of an average to see if the price will revert back to the trend. This is an especially good way to eliminate whipsaws.

    Depending on the technical analysis system you use, you may be able to customize all of these parameters or program them on your own. By adjusting the components of the system, you may be able to increase the profitability or decrease the risk, depending on your trading philosophy. Some program go as far as to offer automatic optimization. All you need to do is select one or several trading systems and the program will backtest the system, changing the parameters in order to find the most profitable combination. Be aware, though, that in this instance you are optimizing a system to a fixed time period in the past, and while the system may have been profitable over the test period, there is no guarantee that those profits will carry over into the future.

    The Price of Peace of Mind

    Whenever you attempt to optimize any trading system, it will be at the expense of profits. The reason for this goes to one of the most basic principles of investing—the risk/return trade-off. Optimizing a system will reduce your risk by lowering the possibility of making incorrect or unnecessary trades. However, by lowering your risk, you are typically decreasing the speed with which the system can react to market changes and, therefore, possibly reducing the overall gain of a trade.

    Not the “Holy Grail”

    Having seen the success moving average trading systems have had in these examples, it is time for a reality check. The one- and two-line moving average systems shown were in the midst of a general uptrend for the stocks. By their very nature, moving averages are most useful in a trending market. When examining periods during which a market or stock is experiencing “sideways” movement, the effectiveness of moving averages is lost. Sideways trading is defined as a period when there is no defined up- or down-trend, when the market is unsure of its next move. Often, the price of a given security bounces back and forth within a defined channel. If and when this channel is broken, a new trend is often established.

    To illustrate this point, examine Figure 4, which shows 20- and 50-day simple moving averages for AGL Resources. From July 1996 until July 1999, AGL experienced a period of sideways trading. During that time, the price fluctuated between roughly $17 and $22—denoted by the two horizontal lines. While the chart shows that the price did move out of that channel—December 1998 and April 1999—for the most part the price traded within this level. If you were using the 20- and 50-day averages in a trading system, your results would have been less than stellar. The six round-trip trades (using only long positions) generated by this system resulted in a gain of 7.3%, or 1.2% per trade. The remaining open trade, which was entered into on May 12, 1999, generated a 9.3% gain thus far, but overall this system probably would have barely broken even over this period if commissions and slippage were taken into account.


    Moving averages are lagging indicators and, therefore, signal price movement that has occurred in the past. The longer the time period you use for a moving average, the older the data to which it is reacting. Ideally moving averages are used in conjunction with other indicators and serve to confirm or refute trend changes.

    The advantage to using moving averages in a trading system—buying or selling when prices penetrate their moving average(s)—is that you will usually be on the “right” side of the market. There may be times, however, when short-term price fluctuations will generate whipsaws, which can have a negative impact on your systems’ performance. Consistently rising or falling prices will eventually lead to a penetration of the moving average on either the up- or downside. However, you will always be entering or exiting positions after the trend has reversed itself. In other words, you will take profits after the price reached its highpoint and you will enter a position after the price has bottomed out.

    Moving average trading systems have both merits and pitfalls. Perhaps the number one thing going for them is the relative ease with which they can be implemented and followed. For someone looking for a simple, systematic approach to technical trading, moving averages might be a good place to start.

    Wayne A. Thorp, CFA is a vice president and the senior financial analyst at AAII and former editor of Computerized Investing. Follow him on Twitter at @WayneTAAII.


    No comments have been added yet. Add your thoughts to the discussion!

    You need to log in as a registered AAII user before commenting.
    Create an account

    Log In