Option Investor
Trader's Corner

Moving Averages and 'Optimal' Settings For Trading

Printer friendly version

I got a question from one of our subscribers recently that asked me about the 'optimal' settings for moving averages. The short answer is that there are none in the sense that different moving average lengths (number of periods that are calculated) and types ('simple', 'exponential', etc.) are a matter of individual PREFERENCE. It's pretty subjective process a lot of the time. There is a more 'objective' determination for length setting involving 'optimization'.

#1. Preference and experience; i.e., what you have found best gauges the trend for the stocks and the indexes that you follow and given the TIME FRAME you like to follow and trade (short-term day to day, weekly, biweekly to monthly, etc). I will give you my take on what works well for moving averages as to type and length, that helps me make trading decisions for the short (2-3-5 days) to intermediate-term (2-3 weeks or a bit longer).

#2. There is something called optimization that can be employed in some trading applications to check a moving average trading strategy or trading 'system'. EXAMPLE: For a given time period (e.g., the last 5000 days), what single moving average would have produced the best 'net profit' had you bought or shorted each time a stock or an index closed above or below that (single) moving average.

More likely, as it's much more commonly used in making trading decisions, would be what set of TWO moving averages had the greatest net profit for a 'crossover' of the two; i.e., a moving average crossover trading strategy. For example, going long when a 10-day average crosses ABOVE the 20-day moving average; or, selling short when the shorter moving average crosses BELOW the longer moving average.

Optimization is the computer running a test to determine, for the history you have, what set of moving averages performed best for certain criteria; e.g., 'net profit'.

For example, I just ran a simple 'optimization' comparing the net profit (over the past 5000 trading days) for all SETS of Simple Moving Averages (SMA) from 5 to 13 as the shorter average, crossing above or below all longer moving average lengths from 21 to 55. And where I only bought when the shorter average crossed above a longer average; no shorting, in order to keep it simple.

I would also note that an optimization computation can also include a test of the optimal 'trailing' exit or stop-out point in case the trade lost money before there was another crossover 'signal', but was also not employed here in the example. The optimization procedure is usually done to determine the most profitable Trading Strategy or System by determining the total point gain; other computations can be done to account for commission costs, 'slippage', etc, in order to account for the real world of trading.

With options, there are more complications, but a rough rule of thumb is that optimizing for the greatest point gain for a set of moving averages (for crossovers) will give us a good set of moving averages with which to determine trend direction. This also assumes that the optimization process has been used for at least several years worth of past price history. There is always something you have to optimize 'FOR'; e.g. greatest point gain.

Results showing what set of two 'crossover' moving averages produced the best profit is shown next for the S&P 100 (OEX) and the Nasdaq 100 (NDX) Indexes. Note that ALL charts are as of the Tuesday (3/7) Close.

The simple optimization test I ran, at least for buys (hey, it's been an UP market!) indicated that using a 6-day and 21-day moving average crossover was the most profitable. This assumes a 'mechanical' use of the moving average crossovers by buying every time the 6-day moving average crossed above the 21-day average and exiting when that was no longer true.

And, like all use of moving average indicators such as in 'trend following' methods, when the market goes sideways, you have the delightful phenomena known as being 'whipsawed' as a result of the shorter average crossing back and forth multiple times BEFORE there is much of a point gain from getting in on the upside crossover.

Not surprisingly because they are related market indexes, the optimal two moving averages used for an optimal (two) moving average crossover indicator for the Nasdaq 100 (NDX) were not hugely different. But it was different, at 7 and 25 days.

Needless to say, moving averages FOLLOW emerging and ongoing trends, versus the use of some indicators like stochastics, RSI and MACD that I wrote about in my last 3 (Wednesday) columns, to ANTICIPATE trend reversals. More on moving averages after a brief update of my market outlook.


The S&P, both the 500 (SPX) and the 100 (OEX) broke below the low end of their two week old trading range and dipped to the are of the 21-day (simple) moving average, my key 'trading' average for the indexes. It has seemed likely that the S&P up trendlines would be reached and the indexes are getting near to them. Hard to predict whether prices will pierce them, since they so often act as strong support. The OEX rebounded to close back above its 21-day average today, so is hanging 'tough' so to speak.

The most bullish change in my indicators is in my call-put 'sentiment' model which continues to fall as shown above. This is a contrary indicator in that the more bearish that traders get collectively, the closer we tend to get to a bottom or eventual bottom.

The Nasdaq is another story and we've seen the two market diverge quite a bit during some periods of the past 12 months. The Nasdaq 100 (NDX) pierced ITS up trendline and fell under its pivotal 21-day average. Since the Nasdaq, like the S&P may just be retreating to the low end of its multi-month trading range, I wouldn't read too much into these technical tea leaves.

What is key is whether the Index can hold above the low end of its range at 1645-1640; a couple of closes below this area, especially back to back, suggests a next downside objective to as low as 1600.

There's a fair amount of talk about a possible big Head & Shoulder's top formation in NDX that shaped up with the highs of December (left 'shoulder'), the January top (the 'head') and the nearly equal to Dec top seen recently (possible right 'shoulder')

Again, I won't read much into this major top stuff unless the 1640-1645 area (the 'neckline') is pierced; if so, a pretty significant top would be suggested by such a break of the late-Dec/Feb lows.

The 'move' in moving average refers to the fact that the value of the average changes as you move forward in time and drop off old data. In the case of a simple 10-day moving average, based on the Close and applied to a daily chart, the most recent 10-day SMA is the sum of the closing prices of the last 10-days divided by 10. Once the trading day is over, the current or most recent Close will cause the close of 11 days ago to drop off as a new ten day calculation is made.

The Simple Moving Average (SMA) is the most common type of moving average and one that I use almost exclusively, as well as being the type that I would say is in most common use. Unless a chart with a moving average applied to it says otherwise assume the average is an SMA.

The SMA is sometimes the only 'type' (e.g., Simple, Weighted, Exponential) moving average choice for 'the' moving average indicator on charts on web sites that have technical indicators that can be applied to price charts. This is not the case of charting applications like Q-Charts, TradeStation, etc.

With the technical analysis software packages, there is usually an option to give more weight to the most recent price activity. A 'weighted' moving average assigns a greater percentage value to the closes for X number of recent bars, whether that bar represents an intraday period (e.g., hourly), a day, a week or a month, thereby giving a REDUCED weighting to older prices. (The practical effect is to make the weighted moving average line follow current prices more closely, with less of a lag than a regular simple moving average.)

Such 'front-loading' is the most popular method of calculating a weighted moving average but is not the only possibility. A variation called linear 'step-weighting' assigns a fixed increment weighting to each day that is dependent on the duration of the average. For example, in such a 5-day weighted average the most recent days close is 5 times the weight of the first day of the 5-day period; the prior day is 4 times the weight of the first day; the third day is 3 times the weight of the first day of the period and so on.

The 'exponentially smoothed' moving average is a type of weighted moving average that is a popular moving average variation and is probably best known through its use in the Moving Average Convergence Divergence (MACD) Indicator. This method allows recent price activity to generate a more rapid change in an average price. A type of 'smoothing' is applied; one that assigns a percent value (for example, .15), to the last bar and this value will be added to a percentage of the previous days close.

Because of this method of calculation, all daily moving average values are modified once the first exponential weighting occurs. The higher the percentage weighting given to the most recent close, the more sensitive will be the resulting moving average to the most recent price change. All data previously used is always part of the new result, although with diminished significance over time.

In the Microsoft daily chart below, a 50-day simple, weighted and exponentially smoothed average are all applied. For a 50-day average and this period of time, the distance between any moving average TYPE (Simple, Weighted, Exponential) relative to the latest Close, especially when there is a rapid price change, is least with the weighted moving average and greatest with the Simple Moving Average (SMA):

You'll note then in the chart above that we were alerted the quickest to price penetrations on the 50-day WEIGHTED moving average; it provided a faster 'trigger' on taking or shifting stock/options positions. Much of the time this faster trigger did not bring major time differences in when prices crossed above/below the different averages. However, there were and are periods when small differences in timing are significant in trading results over time.

When you DECREASE the 'length' (number of trading periods or 'bars' referenced) setting to smaller numbers, such as '21' in the Google (GOOG) chart below, you'll note that the differences between the SMA, Weighted and Exponential moving averages narrow in correspondingly.

To gain a more sensitive 'trigger' to changes AFTER a trend gets underway and while keeping the same length (21 in this case), traders will often increase the WEIGHTING for the last Close or last few closes, as is seen below with the Weighted moving average. Same chart, same 21-day average, but the stock now is quicker to cross above or below the new Weighted Moving Average.

The advantage of the quicker reacting weighting of a weighted moving average is getting out of a position quicker when the trend momentum, up or down, slows. A principle disadvantage, assuming you are mostly relying on the moving average to get you into or out of a position is being 'whipsawed' and having an increased number of losing trades.

In what can be a more effective use of giving STRONGER weight to the most recent close(s), making it a more 'sensitive' average, is as a tool to exit a trend AFTER a big/prolonged move already.

Get back in the stock or Index only when a quicker reacting indicator and trend analysis suggest getting back in the direction of the dominant trend; and possibly then only for SHORTER-term price objectives. OR, get back in when the intermediate chart pattern (e.g., a break of a major trendline) or OTHER intermediate indicators suggest (e.g., a Moving Average Crossover) suggest that the intermediate trend has reversed.

I'll have more to say on moving averages next week and will continue this thread and discuss my favorite type and setting for moving average as well as using moving averages to suggest support and resistance.

This Wed. Trader's Corner article also serves as an adjunct to my weekend 'Index Trader' column. In the article you're reading here I can briefly update a technical picture of the market as of midweek, and then use recent chart/indicator patterns to more fully explain their relevance to trading decisions in general.

More on my specific predictions, support and resistance, etc. is found in my weekend Index Trader column, available on the Option Investor.com WEB site (not part of the e-mailed weekend OI Daily). You will see a web LINK to the Index Trader at the top of your weekend Option Investor Daily e-mail. My most recent (Sat, 3/4) Index Trader can also be viewed online by clicking here.

Please send any technical and Index-related questions for possible use in my next Trader's Corner article to support@optioninvestor.com with 'Leigh Stevens' in the Subject line.

** Good Trading Success! **

Trader's Corner Archives