macd_line
MACD Line (fast EMA - slow EMA)
macd_line(source, fast_period, slow_period, signal_period, fast_matype="ema", slow_matype="ema")
Parameters
MACD Line - macd_line(source, fast_period, slow_period, signal_period, fast_matype="ema", slow_matype="ema")
Difference between fast and slow moving averages.
- source (field): Data series (commonly close)
- fast_period (int): Fast MA period (commonly 12)
- slow_period (int): Slow MA period (commonly 26)
- signal_period (int): Signal period (commonly 9)
- fast_matype (str, optional): Fast MA type ["ema", "sma", "wma"], default "ema"
- slow_matype (str, optional): Slow MA type ["ema", "sma", "wma"], default "ema"
Formula
MACD Line = Fast MA - Slow MA
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 (positive or negative)