A moving average is the average of the last few closing prices, worked out again every day so that it follows the price. A simple moving average (SMA) gives each day the same weight. An exponential moving average (EMA) gives recent days more. At 3,468 turning points in the 32 free stocks and funds on HitBull, the 20-day EMA turned a median of 6 trading days after the price, the 20-day SMA 11 days, and the 50-day SMA 19.
Simple and exponential
A 20-day SMA adds up the last 20 daily closes and divides by 20. Each new day, the oldest close drops out and the newest comes in. A big move stays in the average at full weight for 20 days and then vanishes all at once, which can make the line jump for no reason you can see on that day's candle.
A 20-day EMA moves part of the way toward each new close, 9.5% of the distance for a 20-day period (the fraction is 2 divided by the period plus 1). Old prices fade a little every day instead of dropping out. That makes the EMA hug the price more closely and turn sooner. HitBull starts an EMA from the simple average of its first 20 closes, so both lines begin on the same day.
The period sets the trade-off. A 20-day average covers about a month of trading, a 50-day average about ten weeks, and a 200-day average about a year. The longer the period, the smoother the line and the later it turns.
The period counts candles, not days. On HitBull's hourly candles, with 7 to a trading day, a 20-period average covers about 3 days. On weekly candles it covers about five months. The same setting gives a very different line depending on the chart you play.
Three averages on one chart
Microsoft, Oct 2018 to May 2019
Microsoft fell 18% from October 1, 2018 to its low close of $87.42 on December 24, 2018. Then it turned. The EMA turned up 9 trading days after the low, on January 8, 2019. The 20-day SMA followed after 15 days and the 50-day SMA after 27, on February 4, 2019. By May 6, 2019 the price was +37% from the low. Every line told the truth about the turn, and every one told it late.
How late they turn
To measure the lag on all the free stocks and funds, we took every turning point: a close that was the highest or lowest of the 40 trading days on either side of it. Then we counted the days until each average moved the new way 3 days running.
| Median lag | Average lag | |
|---|---|---|
| 20-day EMA | 6 days | 8.0 days |
| 20-day SMA | 11 days | 10.8 days |
| 50-day SMA | 19 days | 22.0 days |
The EMA was quickest, and the 50-day SMA took about 3 times as long as the EMA. The average lags run higher than the medians because some turns were slow and messy, with the price going sideways before it picked a direction.
Whipsaws: how often price crosses the line
A faster line has a cost. The closer it hugs the price, the more often the price crosses it, and many of those crosses are noise. A whipsaw is a cross that reverses soon after. Here is how often the close crossed each average in a year, counting both directions, and how the price did after a close above the line, against any trading day in the same stocks.
| Crosses a year, per stock | Back below within 5 days | Higher 20 days after a cross above | Higher 60 days after | |
|---|---|---|---|---|
| 20-day EMA | 33 | 60% | 56% | 59% |
| 20-day SMA | 30 | 56% | 56% | 59% |
| 50-day SMA | 18 | 54% | 56% | 59% |
| Any trading day | – | – | 56% | 59% |
On average a stock's price crossed the 20-day EMA about 33 times a year and the 50-day SMA about 18. Most of those crosses didn't last: after a close above the 20-day SMA, the price was back below it within 5 trading days 56% of the time. A trader who bought every cross above and sold every cross below would have traded constantly and been stopped out by noise more often than not. A close above any of the three was followed by a higher price about as often as any day was. On these stocks, crossing an average was not a signal by itself. An average describes the trend that has been. It does not forecast the next one.
These are 32 well-known stocks and funds, most still trading today and most of which rose over the years, so most days look good afterwards. Prices are adjusted for splits and dividends. Past prices don't promise future ones, and this is a simulator, not investment advice.
How traders use them
Most use an average to read direction, not to time a trade: price above a rising 50-day line is an uptrend, and below a falling one a downtrend. Trend following builds a whole approach on that. Two averages together give the golden cross and death cross, which have the same lag problem on a bigger scale. The middle line of Bollinger Bands is a 20-day SMA, and MACD is the gap between two EMAs.
Practise with moving averages
The replay button opens HitBull a month before Microsoft's low, with a 20-day EMA on the chart. Play on Daily candles and decide, candle by candle, when you would have called the turn. Then change the period in the indicator settings and play it again. Adding a second average at the same time comes with Premium.