The MACD line, the signal line and the histogram — each layer answers a different question.
What is the MACD indicator?
Uses the distance between two moving averages as a measure of momentum, with a histogram for the rate of change.
What is Moving Average Convergence Divergence?
The difference between two EMAs (fast and slow) plus a signal line, measuring momentum and trend direction.
Illustrative signals of the rule on simulated data — not a trading recommendation.
Rule: MACD(12,26) crosses above Signal(9): buy; crosses below: sell. Entry = close of the signal candle; SL = entry ∓ 1.5 × ATR(14); TP1/TP2/TP3 = 1R/2R/3R.
Where this indicator is strong
Three reasons Moving Average Convergence Divergence is still used after decades.
The bars shrink before price reverses, earlier than the crossover signal.
Because it is measured in price units, it reflects the real range of the pair you are viewing.
How to read Moving Average Convergence Divergence signals
How MACD produces its number, and what each shape on the chart means.
Formula and how it works
The MACD line = fast EMA (12) minus slow EMA (26) of the close. The Signal line is the EMA (9) of the MACD line itself. Histogram = MACD − Signal, showing the strength or weakness of momentum; MACD crossing above Signal is a bullish signal.
Enter when MACD crosses Signal; use a shrinking histogram as a warning that momentum is fading; MACD–price divergence signals a possible reversal.
The market has clear trending swings, enough for the gap between the two averages to widen.
Sideways phases. MACD wraps around the zero line and crossovers appear constantly without leading to any move.
Entering on every crossover. MACD is a lagging indicator, so its signals need a trend filter in front of them.
Recommended MT5 parameters for Moving Average Convergence Divergence
Default values of the sample file; test them for your market and timeframe.
| Parameter | Description |
|---|---|
| InpFast | Fast EMA period (default 12). |
| InpSlow | Slow EMA period (default 26). |
| InpSignal | EMA period of the signal line (default 9). |
Put the indicator into MetaTrader 5
Four steps, no software needed besides MT5.
Click the download button above; the file saves to your computer under the indicator's name.
In MetaTrader 5 choose File → Open Data Folder, then go to MQL5/Indicators.
Open the file in MetaEditor and click Compile. No errors means the indicator is ready.
Go back to MT5, refresh the Navigator and drag the indicator onto the price chart.
DinexSpace wrote this file from the indicator's public formula, not from any commercial source. You are free to edit and reuse it.
How it differs from MetaTrader 5's built-in indicator
The short answer: the formula is not different. What differs is what you can do with it.
Moving Average Convergence Divergence here gives exactly the same number as MetaTrader 5's built-in version — on purpose. The four points below are what differs, and all four can be read from the very macd.mq5 you download.
- Calls a built-in indicator
- No — the calculation sits in
OnCalculateand can be copied straight into an EA - External libraries
- Not a single #import declaration
- Code length
- 58 lines · 3
inputparameters - How it draws
- A separate window below the price chart · calculated incrementally, does not redraw the past
Why this library promises no secret formula — read the full explanation on the library page.
Which indicators to pair Moving Average Convergence Divergence with, and what you gain
Each indicator only answers one question. Pairing well means covering the right weakness, not stacking more.
- What you gain
- Filters the base trend. A long MA decides whether you may only buy or only sell, MACD handles timing within that direction.
- Note
- MACD is already built from two moving averages, so the MA here must use a much longer period to add any information.
- What you gain
- Double divergence. When both MACD and RSI diverge from price, the warning that momentum is fading comes from two different measures.
- Note
- Both are lagging indicators. Double divergence makes the signal firmer but also later.
- What you gain
- Drops meaningless crossovers. MACD produces many crosses when the market is choppy; ADX removes most of them.
- Note
- The trade-off is missing the start of a new trend, because ADX needs time to rise.
Frequently asked questions about Moving Average Convergence Divergence
How do MACD and RSI differ?
RSI measures the strength of a move and maps it to a fixed 0-100 scale. MACD measures the distance between two moving averages, in price units, so it has no ceiling. RSI suits sideways markets, MACD suits markets with trending swings.
What is the MACD histogram for?
Each bar is the difference between the MACD line and the signal line. Shrinking bars mean the two lines are converging, so momentum is weakening — this comes before the actual crossover, so it is an early warning.
Does Moving Average Convergence Divergence on this page use real or simulated data?
The chart on this page uses a deterministic simulated candle series; it is not market prices or trading results.
Using Moving Average Convergence Divergence in an EA, and further reading
State the candle-close condition, parameters and server time clearly when you put the rule into an EA. See the EAs available on the marketplace to compare options, or read how to read MT5 backtest results before judging any EA.
Other momentum indicators
Indicators in the same momentum group, often used instead of or alongside Moving Average Convergence Divergence.
An indicator draws signals, but when to enter, where to stop out and how much to risk are still your set of rules. Send those rules and DinexSpace builds them into an EA.