Skip to content
StatePath
Tool Atlasmarket.macd

Tool

MACD

market.macd

MarketTrend

Inputs

No typed inputs.

Outputs

Bundle (untagged)

A MACD bundle: the MACD line (fast minus slow EMA), the signal line, and the histogram (MACD minus signal). The histogram crossing zero or the MACD crossing its signal line are the usual read.

MACD (Moving Average Convergence Divergence) is a momentum tool built from two moving averages. It shows when short-term momentum is pulling ahead of or falling behind the longer trend, and is read mainly through its histogram and a signal-line crossover.

MACD overview diagram

How it works

The MACD line is the fast EMA (default 12 bars) minus the slow EMA (default 26 bars). A signal line smooths the MACD line over signal_period bars (default 9). The histogram is MACD minus signal: it grows above zero when momentum is rising and below zero when momentum is fading.

Modes

Source options

Openopen

Build the moving averages from each bar's open price.

Open diagram

When to use: Pick open when the opening price best reflects the moves you trade.

Highhigh

Build the moving averages from each bar's high price.

High diagram

When to use: Pick high when the bar high best reflects the moves you trade.

Lowlow

Build the moving averages from each bar's low price.

Low diagram

When to use: Pick low when the bar low best reflects the moves you trade.

Closeclose

Build the moving averages from each bar's close price. This is the usual choice and the MT5 default.

Close diagram

When to use: Use close for standard MACD behavior; it is the most common setting.

Median (HL2)hl2

Use the bar's median price, the average of high and low, as the input.

Median (HL2) diagram

When to use: Pick median when you want a price that ignores where the bar opened and closed.

Typical (HLC3)hlc3

Use the typical price, the average of high, low and close, as the input.

Typical (HLC3) diagram

When to use: Pick typical to fold the close in with the bar's range for a balanced read.

Average (OHLC4)ohlc4

Use the average price, the mean of open, high, low and close, as the input.

Average (OHLC4) diagram

When to use: Pick average for the smoothest input, weighting every part of the bar equally.

Signal ma type options

EMA signalema

Smooth the signal line with an exponential moving average, which reacts faster to recent MACD values. This is the default and matches MT5.

EMA signal diagram

When to use: Use EMA for standard MACD and for parity with MetaTrader 5.

SMA signalsma

Smooth the signal line with a simple moving average, which weights all recent MACD values equally and reacts more slowly.

SMA signal diagram

When to use: Use SMA when you want a steadier signal line with fewer crossover whipsaws.

Configuration

fast_periodscalar

The length of the fast EMA. Shorter reacts quicker to price; 12 is the classic default.

fast_period diagram
slow_periodscalar

The length of the slow EMA. Longer is smoother and defines the broader trend; 26 is the classic default. It should be larger than fast_period.

slow_period diagram
signal_periodscalar

How many bars are used to smooth the MACD line into the signal line. Larger gives fewer, slower crossovers; 9 is the classic default.

signal_period diagram
sourceenum

Which price each bar contributes to the moving averages (close is the usual choice and the MT5 default).

Choices:openhighlowclosehl2hlc3ohlc4
signal_ma_typeenum

The kind of moving average used to smooth the signal line: ema reacts faster, sma is steadier. ema is the default and matches MetaTrader 5.

Choices:emasma

Connects to

Feeds into

Examples

  • Filter: only take longs when the MACD histogram is above zero (momentum is positive).
  • Detect a bullish trigger when the MACD line crosses above its signal line.

Common mistakes

  • Treating every signal-line crossover as a trade — in choppy markets MACD whipsaws and produces many false crosses.
  • Setting slow_period smaller than fast_period, which inverts the indicator's meaning.

See also