Skip to content
All library documents

MACD Timing with EMA Crossovers and Histogram Signals

Article Strategy library · Author: ChaoZhang

Summary

The document explains MACD as the difference between a fast and slow moving average, with a smoothed signal line used to interpret changes in momentum. Its narrative describes buying when MACD crosses above the signal line and selling when it crosses below. The listed defaults are 12 and 26 periods for the moving averages and 9 for signal smoothing; users can also choose simple rather than exponential averages and select the price input.

There is an important difference between that explanation and the supplied strategy logic: the code enters a long position when the histogram rises and closes it when the histogram falls, rather than implementing the described MACD-signal crossover. The backtest settings identify BTC/USDT futures, but the date-range helper in the source always returns true, so the configurable test dates do not appear to restrict trading. No performance results are provided. The document notes that oscillator signals can whipsaw in ranging markets and recommends broader samples, trend filters, and risk controls before drawing conclusions.

Key ideas

  • MACD subtracts a slower moving average from a faster one and compares the result with a smoothed signal line.
  • The narrative interprets MACD crossings as directional timing signals, while the supplied code trades changes in histogram direction.
  • The listed default periods are 12, 26, and 9, with options for simple averages and different price inputs.
  • Ranging markets can produce false signals, and tuning on a narrow sample can lead to overfitting.
  • The source's date filter appears ineffective because its test-period function always returns true.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.