Macd
Quick Reference
| Property | Value |
|---|---|
| Dimension | technical |
| Category | technical |
| Version | v0.9.0 (Beta) |
| Output Column | macd |
MACD: (ema(fast) - ema(slow)) - trend-following momentum indicator capturing the convergence/divergence of moving averages
Formula
ema((ema(price, fast_window) - ema(price, slow_window)), signal_window)
CDM Inputs
| Column | CDM Table | Description |
|---|---|---|
price | cdm_* | CDM source table |
Parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
fast_window | integer [2, 200] | 12 | Fast EMA window (typically 12) |
slow_window | integer [5, 500] | 26 | Slow EMA window (typically 26) |
signal_window | integer [2, 100] | 9 | Signal line EMA window (typically 9) |
Output
Column: macd
MACD line (fast EMA minus slow EMA)
Market Intuition & Trading Rationale
MACD (Moving Average Convergence Divergence) is a trend-following momentum indicator: ema(ema(price, fast) - ema(price, slow), signal). The inner difference (fast EMA minus slow EMA) is the MACD line — it's positive when the short-term trend is above the long-term trend (bullish) and negative when below (bearish). The outer EMA smooths the MACD line into a "signal line." Crossovers between the MACD line and signal line are traditional entry/exit triggers.
The formula compiles to a 3-node IR DAG: two EMA computations for the fast and slow moving averages, a subtraction to produce the MACD line, and a final EMA for the signal line. The default parameters (12/26/9) are the classic Gerald Appel settings, but the formula accepts any windows.
MACD is inherently trend-following — it performs best in sustained directional markets and worst in choppy, range-bound conditions. The gap between the MACD line and signal line (the histogram) measures trend strength: widening histogram = accelerating trend; narrowing histogram = decelerating trend, potential reversal.
Usage Cases
- MACD/signal crossover: MACD crosses above signal → bullish entry. MACD crosses below signal → bearish entry. This is the classic MACD strategy, best suited for daily and intraday swing trading.
- Zero-line crossover: MACD crossing above zero → long-term trend turning bullish. Below zero → bearish. More reliable than signal crossovers but slower to react.
- Divergence: Price makes a higher high but MACD makes a lower high → bearish divergence (trend weakening). Price makes a lower low but MACD makes a higher low → bullish divergence. These are leading reversal signals.
YAML Definition
name: macd
description: 'MACD: (ema(fast) - ema(slow)) - trend-following momentum indicator capturing
the convergence/divergence of moving averages'
category: technical
version: v0.9.0 (Beta)
dimension: technical
status: Pre-release
required_inputs:
- price
output_column: macd
output_description: MACD line (fast EMA minus slow EMA)
parameters:
fast_window:
type: integer
description: Fast EMA window (typically 12)
required: false
default: 12
constraints:
min: 2
max: 200
slow_window:
type: integer
description: Slow EMA window (typically 26)
required: false
default: 26
constraints:
min: 5
max: 500
signal_window:
type: integer
description: Signal line EMA window (typically 9)
required: false
default: 9
constraints:
min: 2
max: 100
formula: ema((ema(price, fast_window) - ema(price, slow_window)), signal_window)