Trend
MACD
Gerald Appel’s indicator from the 1970s: the difference between two exponential averages (12 and 26 candles) and its own 9-candle average. It catches shifts in short-term momentum.
Rules
- MACD line: EMA 12 minus EMA 26.
- Signal line: EMA 9 of the MACD line.
- A cross from below: buy; from above: sell.
Code for the lab
fast = input(12, 5, 20, 1) slow = input(26, 20, 50, 2) signal = input(9, 5, 15, 1) m = macd(close, fast, slow) sig = macd_signal(close, fast, slow, signal) plot m, sig buy when crossover(m, sig) sell when crossunder(m, sig)
You can change the code right in the lab: the numbers in input(…) become sliders.
Results on eight markets
| Market | CAGR | Drawdown | Trades | Buy and hold: CAGR | Buy and hold: drawdown |
|---|---|---|---|---|---|
| MOEX Russia Index | — | — | — | — | — |
| Sberbank | — | — | — | — | — |
| Gazprom | — | — | — | — | — |
| Gold, $ per ounce | — | — | — | — | — |
| Brent crude, $ per barrel | — | — | — | — | — |
| Bitcoin | — | — | — | — | — |
| Ether | — | — | — | — | — |
| VN-Index | — | — | — | — | — |
| Market | CAGR | Drawdown | Trades | Buy and hold: CAGR | Buy and hold: drawdown |
|---|---|---|---|---|---|
| MOEX Russia Index | — | — | — | — | — |
| Sberbank | — | — | — | — | — |
| Gazprom | — | — | — | — | — |
| Gold, $ per ounce | — | — | — | — | — |
| Brent crude, $ per barrel | — | — | — | — | — |
| Bitcoin | — | — | — | — | — |
| Ether | — | — | — | — | — |
| VN-Index | — | — | — | — | — |
The numbers are calculated in your browser from fresh source candles.
Default parameters, daily candles, a fee and slippage of 0.05% each per trade, no return on cash out of the market, prices without dividends. The test starts once all of the rule’s indicators are calculated.
What research says
Chong and Ng (2008) found on the British FT30 index over 1935–1994 that MACD rules beat buy and hold more often than not. But on five other developed markets, the result held only in Milan and Toronto (Chong, Ng, Liew, 2014), and without an adjustment for the search over many rules.
In our table this rule makes the most trades, and costs eat noticeably into the result. Check it on the Costs tab in the lab.
Original source: Chong, Ng. Technical analysis and the London stock exchange: testing the MACD and RSI rules using the FT30. Applied Economics Letters, 2008
When the rule breaks
- A sideways market: one cross after another.
- Many trades mean many fees and much slippage.
- The signal lags at sharp turns.