macd_line

MACD Line (fast EMA - slow EMA)

macd_line(source, fast_period, slow_period, signal_period, fast_matype="ema", slow_matype="ema")

Parameters

Name Type Description
source field Data series (commonly close)
fast_period int Fast MA period
slow_period int Slow MA period
signal_period int Signal smoothing period

Formula

MACD Line = fast_MA(source, fast_period) - slow_MA(source, slow_period)

Examples

// MACD line crossed above zero (bullish momentum)
macd_line(close, 12, 26, 9) > 0;
// MACD line rising (increasing momentum)
macd_line(close, 12, 26, 9) > macd_line(close, 12, 26, 9)[1];
// MACD with SMA smoothing instead of EMA
macd_line(close, 12, 26, 9, fast_matype="sma", slow_matype="sma") > 0;

Returns

float

Range

fast_period and slow_period are each bound by their own fast_matype/slow_matype family: 2-210 ema (default), 2-105 wilder, or 2-400 windowed sma/wma

See Also

macd_signal, macd_histogram