A moving average crossover is a trading signal produced when one moving average of a price crosses above or below another, or when the price itself crosses a moving average. In the common two-line form, a faster average calculated over a short window is compared with a slower average over a long window. The faster line rising through the slower is read as the start of an uptrend and a signal to buy. The faster line falling through the slower is read as the start of a downtrend and a signal to sell.
The crossover is one of the oldest and simplest rules in technical analysis and a basic building block of trend following. It is easy to compute and to automate, which has made it a standard first example in algorithmic trading and a frequent subject of academic tests of whether technical rules work.
Calculation and signal
The simple moving average over periods is:
- is the closing price periods before time .
- is the number of periods in the window.
A crossover system holds a long position when the fast average is above the slow average and exits, or goes short, when it is below. Suppose the last five daily closes are 10, 11, 12, 13 and 14. The three-day average is and the five-day average is . The fast average is above the slow, so the system is long. If the next closes were 12, 10 and 9, the three-day average would fall to and the five-day average to , and the system would have switched to a sell signal.
Common variants
- Window lengths. The best-known pairing on daily charts is 50 and 200 days. A rise of the 50-day average through the 200-day is popularly called a golden cross and a fall through it a death cross. Shorter-term traders use pairs such as 10 and 30, or 5 and 20.
- Type of average. The exponential moving average and the weighted moving average give more weight to recent prices and so turn sooner than a simple average of the same length.
- Price crossover. The price is compared with a single average, such as the 200-day, which is the same as using a fast window of one period.
- Three averages. A short, medium and long average are required to line up in order before a trade is taken.
- Derived indicators. The moving average convergence divergence indicator plots the gap between two exponential averages and signals when that gap crosses its own average.
Behaviour and trade-offs
A moving average smooths prices and therefore lags them. A crossover confirms a trend only after it has been under way for some time and signals its end only after prices have already turned. The system never buys at the low or sells at the high. What it offers in return is participation in any large, sustained move, since a strong trend will always carry the fast average away from the slow one.
The cost comes when prices move sideways. In a range, the two averages sit close together and cross repeatedly, generating a series of small losing trades known as whipsaws. A typical crossover system loses on more than half of its trades and depends on a few large winners to pay for them. Choosing the windows is a trade-off: shorter windows react faster but whipsaw more, and longer windows give fewer false signals but surrender more of each move. Traders add filters, such as requiring the crossover to persist for several days or to exceed a minimum gap, and controls such as a stop-loss order.
Evidence
A widely cited 1992 study by William Brock, Josef Lakonishok and Blake LeBaron tested moving average and trading range rules on the Dow Jones Industrial Average over nearly a century and found that buy signals were followed by higher returns than sell signals. Later work was more cautious. Researchers pointed out that the popular rules had been selected from many possibilities with the benefit of hindsight, and that after allowing for this data snooping and for trading costs, the profits in equity markets were much weaker in more recent decades. Results have been stronger in futures markets across many asset classes, where related time-series momentum strategies have a long record.
Testing pitfalls
Crossover rules are simple to subject to backtesting, and simple to misuse. Trying every combination of window lengths and reporting the best is a textbook case of overfitting: the winning pair fits the noise of one historical period and has no special merit in the next. More reliable practice fixes the parameters in advance or selects them by walk-forward optimization, checks that neighbouring parameter values give similar results, and tests across many markets.
A test must also trade at prices that were achievable. A signal computed from a day's close cannot be executed at that same close without look-ahead bias, and each trade incurs a transaction cost that fast systems pay many times a year. Charting platforms and their scripting languages make such tests widely available to retail traders, which has increased both the use of crossover rules and the number of over-optimised versions in circulation.