## Moving average

*source: stockcharts.com*

### Introduction

Moving averages smooth the price data to form a trend following indicator. They do not predict price direction, but rather define the current direction with a lag. Moving averages are based on past prices, which means they will lag behind current prices. Price leads and the moving average follows. Moving averages form the building blocks for many other technical indicators and overlays, such as Bollinger Bands, MACD and the McClellan Oscillator. The two most popular types of moving averages are the Simple Moving Average (SMA) and the Exponential Moving Average (EMA). These moving averages can be used to identify the direction of the trend as well as support and resistance levels.

### The Lag Factor

Moving averages lag the price of the underlying security. This makes sense because they are based on past prices. Moving averages will not pick bottoms or tops. Instead, they will turn or be broken after the actual top or bottom has occurred. This is not necessarily a bad thing. Lag is just a fact of life when it comes to moving averages.

The longer the moving average, the more the lag. A 10-day exponential moving average will hug prices quite well and turn shortly after prices turn. Short moving averages are like speed boats - nimble and quick to change. In contrast, a 100-day moving average contains lots of past data that slows it down. Longer moving averages are like ocean tankers - lethargic and slow to change. It takes a sustained price movement for a 100-day moving average to change course. Chart 2 shows the S&P 500 ETF with a 10-day EMA closely following prices and a 100-day SMA grinding higher. Even with the January-February decline, the 100-day SMA held the course and did not turn down. The 50-day SMA fits somewhere between the 10 and 100 day moving averages when it comes to the lag factor.

### Simple Versus Exponential

Even though there are clear differences between simple moving averages and exponential moving averages, one is not necessarily better than the other. Exponential moving averages have less lag and are therefore more sensitive to recent prices - and recent price changes. Exponential moving averages will turn before simple moving averages. Simple moving averages, on the other hand, represent a true average of prices for the entire time period. As such, simple moving averages may be better suited to identify support and resistance levels.

Moving average preference depends on objectives, analytical style and time horizon. Chartists should experiment with both types of moving averages as well as different timeframes to find what suits them the best. Chart 2 shows IBM with the 50-day SMA in red and the 50-day EMA in green. Both peaked in late January, but the decline in the EMA was sharper than the decline in the SMA. The EMA turned up in mid February, but the SMA continued lower until the end of March. Notice that the SMA turned up over a month after the EMA.

### Lengths and Timeframes

The length of the moving average depends on the analytical objectives. Short moving averages (5-20 periods) are best suited for short-term trends and trading. Chartists interested in medium-term trends would opt for 20-60 period moving averages. Long-term investors will prefer moving averages with 100 or more periods. Some moving average lengths are more popular than others. The 200-day moving average is perhaps the most popular. Because of its length, this is clearly a long-term moving average. Next, the 50-day moving average is quite popular for the medium-term trend. Many chartists use the 50-day and 200-day moving averages together. Short-term, a 10-day moving average was quite popular in the past because it was easy to calculate. One simply added the numbers and moved the decimal point.

### Trend Identification

The same signals can be generated using simple or exponential moving averages. As noted above, the preference depends on each individual. These examples below will use both simple and exponential moving averages. The term "moving average" applies to both simple and exponential moving averages.

The direction of the moving average conveys important information about prices. A rising moving average shows that prices are generally increasing. A falling moving average indicates that prices, on average, are falling. A rising long-term moving average reflects a long-term uptrend. A falling long-term moving average reflects a long-term downtrend.

Chart shows 3M (MMM) with a 150-day exponential moving average. This example shows just how well moving averages work when the trend is strong. The 150-day EMA turned down in November 2007 and again in January 2008. Notice that it took a 15% decline to reverse the direction of this moving average. These lagging indicators identify trend reversals as they occur (at best) or after they occur (at worst). MMM continued lower into March 2009 and then surged 40-50%. Notice that the 150-day EMA did not turn up until after this surge. Once it did, however, MMM continued higher the next 12 months. Moving averages work brilliantly in strong trends.

### Double Crossovers

Two moving averages can be used together to generate crossover signals. In Technical Analysis of the Financial Markets, John Murphy calls this the "double crossover method". Double crossovers involve one relatively short moving average and one relatively long moving average. As with all moving averages, the general length of the moving average defines the timeframe for the system. A system using a 5-day EMA and 35-day EMA would be deemed short-term. A system using a 50-day SMA and 200-day SMA would be deemed medium-term, perhaps even long-term.

A bullish crossover occurs when the shorter moving average crosses above the longer moving average. This is also known as a golden cross. A bearish crossover occurs when the shorter moving average crosses below the longer moving average. This is known as a dead cross.

Moving average crossovers produce relatively late signals. After all, the system employs two lagging indicators. The longer the moving average periods, the greater the lag in the signals. These signals work great when a good trend takes hold. However, a moving average crossover system will produce lots of whipsaws in the absence of a strong trend.

There is also a triple crossover method that involves three moving averages. Again, a signal is generated when the shortest moving average crosses the two longer moving averages. A simple triple crossover system might involve 5-day, 10-day and 20-day moving averages.

Chart shows Home Depot (HD) with a 10-day EMA (green dotted line) and 50-day EMA (red line). The black line is the daily close. Using a moving average crossover would have resulting in three whipsaws before catching a good trade. The 10-day EMA broke below the 50-day EMA in late October, but this did not last long as the 10-day moved back above in mid November. This cross lasted longer, but the next bearish crossover occurred near the mid November levels, resulting in another whipsaw. This bearish cross did not last long as the 10-day EMA moved back above the 50-day a few days later. After three bad signals, the fourth signal foreshadowed a strong move as the stock advanced over 20%. There are two takeaways here. First, crossovers are prone to whipsaw. A price or time filter can be applied to help prevent whipsaws. Traders might require the crossover to last 3 days before acting or require 10-day EMA to move above/below the 50-day EMA by a certain amount before acting. Second, MACD can be used to identify and quantify these crossovers. MACD (5,50,1) will show a line representing the difference between the two exponential moving averages. MACD turns positive during a golden cross and negative during a dead cross. The Percentage Price Oscillator (PPO) can be used the same way to show percentage differences. Note that MACD and the PPO are based on exponential moving averages and will not match up with simple moving averages.

Chart 6 shows Oracle (ORCL) with the 50-day EMA, 200-day EMA and MACD(50,200,1). There were four moving average crossovers over a 2 1/2 year period. The first three resulted in whipsaws or bad trades. A sustained trend began with the fourth crossover as ORCL advanced to the mid 20s. Once again, moving average crossovers work great when the trend is strong, but produce losses in the absence of a trend.

### Price Crossovers

Moving averages can also be used to generate signals with simple price crossovers. A bullish signal is generated when prices move above the moving average. A bearish signal is generated when prices move below the moving average. Short-term signals would utilize a short moving average, such as 10 days. Long moving averages, such as 200 days, would be better suited for long-term signals.

Price crossovers can be combined to trade within the bigger trend. The longer moving average sets the tone for the bigger trend and the shorter moving average is used to generate the signals. One would look for bullish price crosses only when prices are already above the longer moving average. This would be trading in harmony with the bigger trend. For example, if price is above the 200-day moving average, chartists would only focus on signals where price moves above the 50-day moving average. Obviously, a move below the 50-day moving average would precede such a signal, but such bearish crosses would be ignored because they are not in harmony with the bigger trend. A bearish cross would simply suggest a pullback within a bigger uptrend. A cross back above the 50-day moving average would signal an upturn in prices and continuation of the bigger uptrend.

Chart 7 shows Emerson Electric (EMR) with the 50-day EMA and 200-day EMA. The stock moved above and held above the 200-day moving average in August. There were dips below the 50-day EMA in early November and again in early February. Prices quickly moved back above the 50-day EMA to provide bullish signals (green arrows) in harmony with the bigger uptrend. MACD(1,50,1) is shown in the indicator window to confirm price crosses above or below the 50-day EMA. The 1-day EMA equals the closing prices. MACD(1,50,1) is positive when the close is above the 50-day EMA and negative when the close is below the 50-day EMA.

### Death Cross and Golden Cross

On a stock chart, the *Death cross* occurs when the *50-day MA falls below the 200-day MA*. As the name implies, a Death Cross is associated with sharp downward price movement and can be used as a sell signal in the belief that a significant downtrend will follow. The reverse of this event is known as a *Golden Cross where the 50-day MA rises above the 200-day MA*, a bullish signal.

### Support and Resistance

Moving averages can also act as support in an uptrend and resistance in a downtrend. A short-term uptrend might find support near the 20-day simple moving average, which is also used in Bollinger Bands. A long-term uptrend might find support near the 200-day simple moving average, which is the most popular long-term moving average. If fact, the 200-day moving average may offer support or resistance simply because it is so widely used. It is almost like a self-fulfilling prophecy.

Chart shows the NY Composite with the 200-day simple moving average from mid 2004 until the end of 2008. The 200-day provided support numerous times during the advance. Once the trend reversed with a double top support break, the 200-day moving average acted as resistance around 9500.

Do not expect exact support and resistance levels from moving averages, especially longer moving averages. Markets are driven by emotion, which makes them prone to overshoots. Instead of exact levels, chartists can consider using support and resistance zones around a moving average.

### Conclusions

The advantages of using moving averages need to be weighed against the disadvantages. Moving averages are trend following, or lagging, indicators that will always be a step behind. This is not necessarily a bad thing though. After all, the trend is your friend and it is best to trade in the direction of the trend. Moving averages will help ensure that a trader is in line with the current trend. However, markets, stocks and securities spend a great deal of time in trading ranges, which render moving averages ineffective. Once in a trend, moving averages will keep you in, but also give late signals. Don't expect to sell at the top and buy at the bottom using moving averages. As with most technical analysis tools, moving averages should not be used on their own, but in conjunction with other complementary tools. Chartists could use moving averages to define the overall trend and then use RSI to define overbought/oversold levels.

### Moving Average Mathematical Definition

In statistics, a moving average or rolling average is one of a family of similar techniques used to analyze time series data. It is applied in finance and especially in technical analysis. It can also be used as a generic smoothing operation, in which case the raw data need not be a time series.

A moving average series can be calculated for any time series. In finance it is most often applied to stock prices, returns or trading volumes. Moving averages are used to smooth out short-term fluctuations, thus highlighting longer-term trends or cycles. The threshold between short-term and long-term depends on the application, and the parameters of the moving average will be set accordingly.

Mathematically, each of these moving averages is an example of a convolution. These averages are also similar to the low-pass filters used in signal processing.

### Prior moving average

A simple moving average (SMA) is the unweighted mean of the previous n data points. For example, a 10-day simple moving average of closing price is the mean of the previous 10 days' closing prices. If those prices are pM, pM − 1... pM − 9 then the formula is

When calculating successive values, a new value comes into the sum and an old value drops out, meaning a full summation each time is unnecessary,

In technical analysis there are various popular values for n, like 10 days, 40 days, or 200 days. The period selected depends on the kind of movement one is concentrating on, such as short, intermediate, or long term. In any case moving average levels are interpreted as support in a rising market, or resistance in a falling market.

In all cases a moving average lags behind the latest data point, simply from the nature of its smoothing. An SMA can lag to an undesirable extent, and can be disproportionately influenced by old data points dropping out of the average. This is addressed by giving extra weight to more recent data points, as in the weighted and exponential moving averages.

One characteristic of the SMA is that if the data has a periodic fluctuation, then applying an SMA of that period will eliminate that variation (the average always containing one complete cycle). But a perfectly regular cycle is rarely encountered in economics or finance.