Tool
MACD
market.macd
Inputs
No typed inputs.
Outputs
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.
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
Build the moving averages from each bar's open price.
When to use: Pick open when the opening price best reflects the moves you trade.
Build the moving averages from each bar's high price.
When to use: Pick high when the bar high best reflects the moves you trade.
Build the moving averages from each bar's low price.
When to use: Pick low when the bar low best reflects the moves you trade.
Build the moving averages from each bar's close price. This is the usual choice and the MT5 default.
When to use: Use close for standard MACD behavior; it is the most common setting.
Use the bar's median price, the average of high and low, as the input.
When to use: Pick median when you want a price that ignores where the bar opened and closed.
Use the typical price, the average of high, low and close, as the input.
When to use: Pick typical to fold the close in with the bar's range for a balanced read.
Use the average price, the mean of open, high, low and close, as the input.
When to use: Pick average for the smoothest input, weighting every part of the bar equally.
Signal ma type options
Smooth the signal line with an exponential moving average, which reacts faster to recent MACD values. This is the default and matches MT5.
When to use: Use EMA for standard MACD and for parity with MetaTrader 5.
Smooth the signal line with a simple moving average, which weights all recent MACD values equally and reacts more slowly.
When to use: Use SMA when you want a steadier signal line with fewer crossover whipsaws.
Configuration
The length of the fast EMA. Shorter reacts quicker to price; 12 is the classic default.
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.
How many bars are used to smooth the MACD line into the signal line. Larger gives fewer, slower crossovers; 9 is the classic default.
Which price each bar contributes to the moving averages (close is the usual choice and the MT5 default).
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.
Connects to
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.