StockBeatStockBeat
Basics
  • Number Series
  • Boolean Series
  • Examples
  • Indicators
Alarms
Concepts
Basics
  • Number Series
  • Boolean Series
  • Examples
  • Indicators
Alarms
Concepts
  • Signals

    • Number Series
    • Boolean Series
    • Signal Examples
    • Indicators

      • Indicators
      • MFI (Money Flow Index)
      • ATR (Average True Range)
      • CCI (Commodity Channel Index)
      • CE (Chandelier Exit)
      • ER (Kaufman's Efficiency Ratio)
      • KC (Keltner Channel)
      • SMA (Simple Moving Average)
      • EMA (Exponential Moving Average)
      • MACD (Moving Average Convergence Divergence)
      • PPO (Percentage Price Oscillator)
      • RSI (Relative Strength Index)
      • FSO (Fast Stochastic Oscillator)
      • SSO (Slow Stochastic Oscillator)
      • BB (Bollinger Bands)
      • MAD (Mean Absolute Deviation)

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

NameDescription
fast_periodperiod for fast EMA
slow_periodperiod for slow EMA
signal_periodperiod of signal EMA
typeone 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.

Last Updated:: 2/12/26, 8:03 AM
Contributors: ErenKizilay
Prev
EMA (Exponential Moving Average)
Next
PPO (Percentage Price Oscillator)