ta.macd
Compare a fast and a slow average to read momentum shifts and crossovers.
ta.macd(source, fast, slow, signal)Moving Average Convergence/Divergence: [ema(fast) - ema(slow), ema of that over signal, their difference].
Parameters
A series parameter takes a value on every bar. A constant parameter must be known before the first bar, such as a number or an input.
| Name | Kind | Type | Default | Range | Description |
|---|---|---|---|---|---|
source | Series | number | - | - | The series to read. |
fast | Constant | number | 12 | 1 to 10000 | Window in observed bars. |
slow | Constant | number | 26 | 1 to 10000 | Window in observed bars. |
signal | Constant | number | 9 | 1 to 10000 | Window in observed bars. |
Outputs
| Name | Type |
|---|---|
macd | number |
signal | number |
hist | number |
The outputs come back in this order: [macd, signal, hist] = ta.macd(…).
Warm-up and missing values
- Warm-up
slow + signal - 1bars. Names in the warm-up are this operator’s parameters.- Missing values
- The first output is na until the slow exponential average warms up. The signal and histogram are na until the signal average warms up on top of that.
Example
[macdLine, signalLine, hist] = ta.macd(close, 12, 26, 9)[macdLine, signalLine, hist] = ta.macd(close, 12, 26, 9)
plot(hist, "Histogram")
plot(macdLine, "Line")