
Moving averages smooth the price data to form a trend following indicator. They do not predict price direction, but rather define the current direction, though they lag due to being based on past prices. Despite this, moving averages help smooth price action and filter out the noise. They also 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 or define potential support and resistance levels.
Here's a chart with both an SMA and an EMA on it:
A simple moving average is formed by computing the average price of a security over a specific number of periods. Most moving averages are based on closing prices; for example, a 5day simple moving average is the fiveday sum of closing prices divided by five. As its name implies, a moving average is an average that moves. Old data is dropped as new data becomes available, causing the average to move along the time scale. The example below shows a 5day moving average evolving over three days.
Daily Closing Prices: 11,12,13,14,15,16,17 First day of 5day SMA: (11 + 12 + 13 + 14 + 15) / 5 = 13 Second day of 5day SMA: (12 + 13 + 14 + 15 + 16) / 5 = 14 Third day of 5day SMA: (13 + 14 + 15 + 16 + 17) / 5 = 15
The first day of the moving average simply covers the last five days. The second day of the moving average drops the first data point (11) and adds the new data point (16). The third day of the moving average continues by dropping the first data point (12) and adding the new data point (17). In the example above, prices gradually increase from 11 to 17 over a total of seven days. Notice that the moving average also rises from 13 to 15 over a threeday calculation period. Also, notice that each moving average value is just below the last price. For example, the moving average for day one equals 13 and the last price is 15. Prices the prior four days were lower and this causes the moving average to lag.
Exponential moving averages (EMAs) reduce the lag by applying more weight to recent prices. The weighting applied to the most recent price depends on the number of periods in the moving average. EMAs differ from simple moving averages in that a given day's EMA calculation depends on the EMA calculations for all the days prior to that day. You need far more than 10 days of data to calculate a reasonably accurate 10day EMA.
There are three steps to calculating an exponential moving average (EMA). First, calculate the simple moving average for the initial EMA value. An exponential moving average (EMA) has to start somewhere, so a simple moving average is used as the previous period's EMA in the first calculation. Second, calculate the weighting multiplier. Third, calculate the exponential moving average for each day between the initial EMA value and today, using the price, the multiplier, and the previous period's EMA value. The formula below is for a 10day EMA.
Initial SMA: 10period sum / 10 Multiplier: (2 / (Time periods + 1) ) = (2 / (10 + 1) ) = 0.1818 (18.18%) EMA: {Close  EMA(previous day)} x multiplier + EMA(previous day).
A 10period exponential moving average applies an 18.18% weighting to the most recent price. A 10period EMA can also be called an 18.18% EMA. A 20period EMA applies a 9.52% weighting to the most recent price (2/(20+1) = .0952). Notice that the weighting for the shorter time period is more than the weighting for the longer time period. In fact, the weighting drops by half every time the moving average period doubles.
If you want to use a specific percentage for an EMA, you can use this formula to convert it to time periods and then enter that value as the EMA's parameter:
Time Period = (2 / Percentage)  1 3% Example: Time Period = (2 / 0.03)  1 = 65.67 time periods
Below is a spreadsheet example of a 10day simple moving average and a 10day exponential moving average for Intel. The SMA calculation is straightforward and requires little explanation: the 10day SMA simply moves as new prices become available and old prices drop off. The exponential moving average in the spreadsheet starts with the SMA value (22.22) for its first EMA value. After the first calculation, the normal EMA formula is used.
The formula for an EMA incorporates the previous period's EMA value, which in turn incorporates the value for the EMA value before that, and so on. Each previous EMA value accounts for a small portion of the current value. Therefore, the current EMA value will change depending on how much past data you use in your EMA calculation. Ideally, for a 100% accurate EMA, you should use every data point the stock has ever had in calculating the EMA, starting your calculations from the first day the stock existed. This is not always practical, but the more data points you use, the more accurate your EMA will be. The goal is to maximize accuracy while minimizing calculation time.
The spreadsheet example below goes back 30 periods. With only 30 data points incorporated in the EMA calculations, the 10day EMA values in the spreadsheet are not very accurate. On our charts, we calculate back at least 250 periods (typically much further), resulting in EMA values that are accurate to within a fraction of a penny.
The longer the moving average, the more the lag. A 10day exponential moving average will hug prices quite closely and turn shortly after prices turn. Short moving averages are like speedboats  nimble and quick to change. In contrast, a 100day 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 larger and longer price movement for a 100day moving average to change course.
Click here for a live version of the chart.
The chart above shows the S&P 500 ETF with a 10day EMA closely following prices and a 100day SMA grinding higher. Even with the JanuaryFebruary decline, the 100day SMA held the course and did not turn down. The 50day SMA fits somewhere between the 10 and 100day moving averages when it comes to the lag factor.
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 or 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 the best fit. The chart below shows IBM with the 50day SMA in red and the 50day 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 midFebruary, but the SMA continued lower until the end of March. Notice that the SMA turned up over a month after the EMA.
The length of the moving average depends on the analytical objectives. Short moving averages (520 periods) are best suited for shortterm trends and trading. Chartists interested in mediumterm trends would opt for longer moving averages that might extend 2060 periods. Longterm investors will prefer moving averages with 100 or more periods.
Some moving average lengths are more popular than others. The 200day moving average is perhaps the most popular. Because of its length, this is clearly a longterm moving average. Next, the 50day moving average is quite popular for the mediumterm trend. Many chartists use the 50day and 200day moving averages together. Shortterm, a 10day moving average was quite popular in the past because it was easy to calculate. One simply added the numbers and moved the decimal point.
The direction of the moving average conveys important information about prices, whether that average is simple or exponential. A rising moving average shows that prices are generally increasing. A falling moving average indicates that prices, on average, are falling. A rising longterm moving average reflects a longterm uptrend. A falling longterm moving average reflects a longterm downtrend.
The chart above shows 3M (MMM) with a 150day exponential moving average. This example shows just how well moving averages work when the trend is strong. The 150day 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 4050%. Notice that the 150day 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.
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 5day EMA and 35day EMA would be deemed shortterm. A system using a 50day SMA and 200day SMA would be deemed mediumterm, perhaps even longterm.
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 death cross (sometimes referred to 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 5day, 10day, and 20day moving averages.
The chart above shows Home Depot (HD) with a 10day EMA (green dotted line) and 50day EMA (red line). The black line is the daily close. Using a moving average crossover would have resulted in three whipsaws before catching a good trade. The 10day EMA broke below the 50day EMA in late October (1), but this did not last long as the 10day moved back above in midNovember (2). This cross lasted longer, but the next bearish crossover in January (3) occurred near late November price levels, resulting in another whipsaw. This bearish cross did not last long as the 10day EMA moved back above the 50day a few days later (4). 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 the 10day EMA to move above/below the 50day EMA by a certain amount before acting. Second, MACD can be used to identify and quantify these crossovers. MACD (10,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 death 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.
This chart shows Oracle (ORCL) with the 50day EMA, 200day 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 mid20s. Once again, moving average crossovers work great when the trend is strong, but produce losses in the absence of a trend.
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. 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 200day moving average, chartists would only focus on signals when price moves above the 50day moving average. Obviously, a move below the 50day moving average would precede such a signal, but such bearish crosses would be ignored because the bigger trend is up. A bearish cross would simply suggest a pullback within a bigger uptrend. A cross back above the 50day moving average would signal an upturn in prices and continuation of the bigger uptrend.
The next chart shows Emerson Electric (EMR) with the 50day EMA and 200day EMA. The stock crossed and held above the 200day moving average in August. There were dips below the 50day EMA in early November and again in early February. Prices quickly moved back above the 50day 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 50day EMA. The 1day EMA equals the closing price. MACD(1,50,1) is positive when the close is above the 50day EMA and negative when the close is below the 50day EMA.
Moving averages can also act as support in an uptrend and resistance in a downtrend. A shortterm uptrend might find support near the 20day simple moving average, which is also used in Bollinger Bands. A longterm uptrend might find support near the 200day simple moving average, which is the most popular longterm moving average. In fact, the 200day moving average may offer support or resistance simply because it is so widely used. It is almost like a selffulfilling prophecy.
The chart above shows the NY Composite with the 200day simple moving average from mid2004 until the end of 2008. The 200day provided support numerous times during the advance. Once the trend reversed with a double top support break, the 200day 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, moving averages can be used to identify support or resistance zones.
Learn More: Support and Resistance
Several moving averages with different lookback periods can be plotted on the same chart. The moving average lines resemble a ribbon moving across the chart:
In addition to analyzing individual moving average lines on the ribbon, chartists can glean information from the ribbon itself. If the lines are running in parallel, this indicates a strong trend. If the ribbon is expanding (the lines are moving further apart over time), this indicates the trend is coming to an end. If the ribbon is contracting (the lines are moving closer together or even crossing), this can indicate the start of a new trend.
Learn More: Moving Average Ribbon
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 ensure that a trader is in line with the current trend. Even though the trend is your friend, 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 can use moving averages to define the overall trend and then use RSI to define overbought or oversold levels.
Moving averages are available in SharpCharts as a price overlay. Using the Overlays dropdown menu, users can choose either a simple moving average or an exponential moving average. The first parameter is used to set the number of time periods.
An optional parameter can be added to specify which price field should be used in the calculations  “O” for the Open, “H” for the High, “L” for the Low, and “C” for the Close. A comma is used to separate parameters.
Another optional parameter can be added to shift the moving averages to the left (past) or right (future). A negative number (10) would shift the moving average to the left 10 periods. A positive number (10) would shift the moving average to the right 10 periods.
Multiple moving averages can be overlaid the price plot by simply adding another overlay line to the workbench. StockCharts members can change the colors and style to differentiate between multiple moving averages. After selecting an indicator, open “Advanced Options” by clicking the little green triangle.
“Advanced Options” can also be used to add a moving average overlay to other technical indicators like RSI, CCI, and Volume.
Click here
for a live chart with several different moving averages.
StockCharts members can screen for stocks based on Moving Average values. Below are some example scans that can be used for Moving Averagebased signals. Simply copy the scan text and paste it into the Scan Criteria box in the Advanced Scan Workbench.
Members can also set up alerts to notify them when a Moving Averagebased signal is triggered for a stock. Alerts use the same syntax as scans, so the sample scans below can be used as a starting point for setting up alerts as well. Simply copy the scan text and paste it into the Alert Criteria box in the Technical Alert Workbench.
This scan looks for stocks with a rising 150day simple moving average and a bullish cross of the 5day EMA and 35day EMA. The 150day moving average is rising as long as it is trading above its level five days ago. A bullish cross occurs when the 5day EMA moves above the 35day EMA on aboveaverage volume.
[type = stock] AND [country = US] AND [SMA(20,Volume) > 40000] AND [SMA(60,Close) > 20] AND [SMA(150,Close) > 5 days ago SMA(150,Close)] AND [EMA(5,Close) > EMA(35,Close)] AND [Yesterday's EMA(5,Close) < Yesterday's EMA(35,Close)] AND [Volume > SMA(200,Volume)]
This scan looks for stocks with a falling 150day simple moving average and a bearish cross of the 5day EMA and 35day EMA. The 150day moving average is falling as long as it is trading below its level five days ago. A bearish cross occurs when the 5day EMA moves below the 35day EMA on aboveaverage volume.
[type = stock] AND [country = US] AND [SMA(20,Volume) > 40000] AND [SMA(60,Close) > 20] AND [SMA(150,Close) < 5 days ago SMA(150,Close)] AND [EMA(5,Close) < EMA(35,Close)] AND [Yesterday's EMA(5,Close) > Yesterday's EMA(35,Close)] AND [Volume > SMA(200,Volume)]
For more details on the syntax to use for Moving Average scans, please see our Scanning Indicator Reference in the Support Center.
Arthur Hill on Moving Average Crossovers
Learn about the limitations of using trading systems based solely on moving average crossovers.
Trade with Moving Averages by Colin Alexander
May 1993  Stocks & Commodities V. 11:6 (257260)
Applying Moving Averages by John Sweeney
Mar 1998  Stocks & Commodities
John Murphy's Technical Analysis of the Financial Markets contains a chapter devoted to moving averages, their various uses and their pros and cons. In addition, Murphy shows how moving averages work with Bollinger Bands and channelbased trading systems.