MACD Signal Crossover (Trend)
Buys when the MACD line (12/26) crosses above its 9-bar signal line and sells when it crosses back below.
How It Works
- Compute the MACD line — the 12-bar EMA minus the 26-bar EMA — and its signal line, a 9-bar EMA of the MACD itself.
- Buy when the MACD line crosses above its signal line: momentum has turned up faster than its own recent trend.
- Sell when the MACD line crosses back below the signal line.
Worked example. MACD has been recovering: yesterday −0.4 against a signal of −0.2, today +0.1 against −0.1. The line has crossed above its signal — buy. When MACD later drops back through the signal line, the position closes.
The Math Behind The Indicators
Everything runs on closing prices of the traded timeframe: P is a close, Pt today's close, and N counts bars — one bar is one candle of that timeframe, so 20 bars on a 1h chart is 20 hours.
- Exponential Moving Average (EMA)
- A running average that blends each new close into yesterday's value, so old prices fade away gradually instead of dropping out all at once. The blend factor α is larger for shorter periods, which makes short EMAs faster to react.
- Example: With N = 19, α = 2 / 20 = 0.1. If yesterday's EMA was 100 and today's close is 110, the new EMA is 0.1·110 + 0.9·100 = 101 — it moves toward the new price but keeps most of its history.
- MACD
- The distance between a fast 12-bar EMA and a slow 26-bar EMA. When the fast average pulls above the slow one, MACD is positive and upward momentum is building. The signal line — a 9-bar EMA of the MACD itself — smooths it, so crossings between the two mark shifts in momentum.
- Example: If EMA12 = 105 and EMA26 = 102, MACD = +3: the recent trend runs above the longer one. With the signal line at 2.5, MACD sits above its signal — momentum is strengthening.