MACD (Moving Average Convergence Divergence)
MACD tracks the relationship between two moving averages and plots the difference as a line and histogram. It tells your agent when momentum is building, fading, or flipping direction — often before it's obvious in price.
What MACD Tells Your Agent
MACD has three components your agent reads together:
- MACD Line — The difference between a fast EMA (12) and slow EMA (26). When this line is above zero, short-term momentum is bullish. Below zero, bearish.
- Signal Line — A smoothed average (9-period) of the MACD line. When MACD crosses above the signal, momentum is turning up. Below it, turning down.
- Histogram — The gap between MACD and the signal line. When the histogram is growing, the move is accelerating. When it's shrinking, the move is losing steam.
Your agent reads these three pieces together. A MACD crossover above the signal line says "momentum is shifting bullish." An expanding histogram says "and it's getting stronger." That combination is a high-confidence signal.
How Your Agent Calls MACD
The agent sends:
- Timeframe — Which chart to analyze (5-minute, 1-hour, daily, etc.)
- Fast period — The short EMA (default: 12)
- Slow period — The long EMA (default: 26)
- Signal period — The smoothing period (default: 9)
The agent gets back:
macd_line: 125.40— MACD is above zero (bullish momentum)signal_line: 98.20— MACD is above the signal (bullish crossover)histogram: 27.20— The gap is positive and growing (acceleration)macd_state: "bullish"— Summary state
The agent sees all of this and knows: momentum is bullish, it just crossed over, and it's accelerating. If the strategy says "enter on MACD crossovers with histogram acceleration," this is the setup.
Multi-Timeframe MACD
Your agent can read MACD across multiple timeframes:
- Daily MACD — Histogram turning positive. The big-picture trend is shifting bullish.
- 1-hour MACD — Bullish crossover confirmed. Medium-term momentum agrees.
- 5-minute MACD — Histogram expanding. Short-term acceleration for a precise entry.
When MACD aligns across timeframes, the agent's confidence goes up significantly. A MACD crossover on the 5-minute is a weak signal. The same crossover confirmed on the 1-hour and daily? That's a much stronger move.
What MACD Is Good For
Catching momentum shifts early — MACD often turns before price does. A shrinking histogram tells your agent that the current move is running out of gas, even while price is still trending. The agent can prepare to exit or reverse.
Signal line crossovers — The classic MACD trade. When MACD crosses above its signal line, momentum has shifted bullish. Your agent can act on these instantly.
Zero line crosses — When MACD crosses above zero, the short-term average has overtaken the long-term average. The trend has officially shifted. This is a slower but more reliable signal.
Divergence — When price makes a new high but MACD makes a lower high, momentum isn't supporting the move. Your agent can detect this and either tighten stops or prepare for a reversal.
What MACD Isn't Good For
MACD is a lagging indicator — it's based on moving averages, so it reacts to what already happened. In choppy, trendless markets, MACD will whipsaw with constant false crossovers. Pairing it with a trend indicator like EMA helps your agent avoid taking MACD signals when there's no real trend to trade.
Next Steps
- EMA — Add trend direction as a filter
- RSI — Add overbought/oversold context
- Understanding Indicators — Inputs, outputs, and multi-timeframe analysis