MACD (Moving Average Convergence Divergence)
The MACD (Moving Average Convergence Divergence) is a trend-following momentum indicator that shows the relationship between two moving averages of a security’s price. The MACD is calculated by subtracting the 26-period Exponential Moving Average (EMA) from the 12-period EMA. The result of that calculation is the MACD line. A nine-day EMA of the MACD called the "signal line," is then plotted on top of the MACD line, which can function as a trigger for buy and sell signals.
Arguments
| Name | Description |
|---|---|
fast_period | period for fast EMA |
slow_period | period for slow EMA |
signal_period | period of signal EMA |
type | one of value, signal or histogram |
Useful Signal Expressions
1. MACD Histogram Crossover (Bullish)
Signal:
close().macd(12, 26, 9, histogram).crosses_above(0)
Explanation: The MACD histogram crosses above the zero line, which is a bullish signal.
2. MACD Histogram Crossover (Bearish)
Signal:
close().macd(12, 26, 9, histogram).crosses_below(0)
Explanation: The MACD histogram crosses below the zero line, which is a bearish signal.
3. MACD Line crosses above Signal Line
Signal:
close().macd(12, 26, 9, value).crosses_above(close().macd(12, 26, 9, signal))
Explanation: The MACD line crosses above the signal line, a classic bullish MACD signal.
