Diver MACD Indicator for MT4 and MT5

Written by Dominic Walsh · Published · Last updated

Divergence is a comparison of two pivots, not a comparison of two lines. The diver macd indicator finds pivots in the reading itself, checks what price did at those same bars, and marks the case where price made a lower low while the reading made a higher one.

This build ships as a compiled .ex4 for MT4 and .ex5 for MT5; the screenshots below come from EURUSD H1.

Platforms MT4 (.ex4) + MT5 (.ex5)
Chart window Separate window
Plots 5: MACD, Signal, Histogram, Bullish Divergence, Bearish Divergence
Alerts popup
Inputs 10

Plots this indicator declares

Three pane plots and two divergence marks.

`MACD` traces dodger blue at width 2.

`Signal` traces orange beside it.

`Histogram` fills silver between them.

`Bullish Divergence` marks lime at width 3.

`Bearish Divergence` marks red at the same width.

  • MACD: line, dodger blue, width 2
  • Signal: line, orange, width 2
  • Histogram: histogram, silver, width 2
  • Bullish Divergence: arrow, lime, width 3, arrow code 233
  • Bearish Divergence: arrow, red, width 3, arrow code 234
diver macd indicator: A confirmed divergence in the pane, EURUSD H1.
A confirmed divergence in the pane, EURUSD H1.

What the file computes

The reading itself

`InpFastEMA` `12` less `InpSlowEMA` `26`, with `InpSignalSMA` `9` smoothing the result. Standard periods, and the histogram is the gap between the two lines.

Finding pivots in the reading

`InpPivotLeft` `3` and `InpPivotRight` `3` bars define one. The right-hand side is what costs the confirmation delay, since those bars have to close first.

When the two differ

`InpDivLookback` `60` bounds the search back for a previous pivot. Price making a lower low while the reading makes a higher one is the bullish case.

Interpreting what you see

Marks sit on the reading’s pivot, not on price.

A chart arrow also appears beside the candle.

`InpArrowOffsetAtr` `0.6` sets how far that arrow sits.

`InpMinPivotGap` `5` sets how far apart two pivots must sit.

Divergence confirms three bars late by design.

Warm-up needs about forty bars.

Alert channels in this build: popup, one message per closed bar.

`InpEnableAlerts` `true` raises a terminal message when a divergence confirms on a closed bar. This build keeps the terminal as its only destination, with no handset, mail or audio route among its inputs at all.

Every Diver Macd Indicator input

Core settings

Setting What it does Default
InpFastEMA Fast EMA period. Quicker average inside the reading, `12`. 12
InpSlowEMA Slow EMA period. Slower one, `26`. 26
InpSignalSMA Signal SMA period. Smoothing over their difference, `9`. 9
InpPivotLeft Pivot left bars. Bars left of a pivot, `3`. 3
InpPivotRight Pivot right bars (confirmation). Bars right of it, the confirmation cost, `3`. 3
InpDivLookback Bars to search back for previous pivot. Bars searched back for the previous pivot, `60`. 60
InpMinPivotGap Minimum bars between two pivots. Minimum bars between two compared pivots, `5`. 5
InpAtrPeriod ATR period for arrow offset. Window behind that range figure, `14`. 14

Display settings

Setting What it does Default
InpArrowOffsetAtr Chart-arrow offset in ATR units. Range multiples the chart arrow stands off, `0.6`. 0.6

Alert settings

Setting What it does Default
InpEnableAlerts Enable bar-close alert. Speak on a bar-close divergence, `true`. on
diver macd indicator: Inputs panel, the pivot rules under the periods.
Inputs panel, the pivot rules under the periods.

Timeframes worth trying

Divergence needs swings far enough apart to compare. EURUSD H1 is the reference chart, where sixty bars of lookback covers two and a half days. On M5 the pivots crowd together. On H4 a divergence spans a fortnight.

What it misses

Divergence can persist for a long time before resolving.

Three bars of confirmation is three bars of delay.

Sixty bars of lookback can pair unrelated pivots.

A disagreement is a warning, not a turn.

Copy the compiled Diver Macd Indicator file into your MQL4/Indicators folder, and the MT5 build into MQL5/Indicators, then restart the terminal and drag it onto a chart. The step-by-step guide with screenshots is at how to install MT4 and MT5 indicators.

Download the Diver Macd Indicator for MT4 and MT5

The zip holds the compiled Diver Macd Indicator build for MT4 and MT5, plus a short README. Compiled files only, no source. Enter your email below and the download link arrives in your inbox.

Download this indicator free

Enter your email and the file is yours. You also get the full MT4 and MT5 library.

  • 1,380+ indicators
  • MT4 and MT5 files
  • No spam, unsubscribe any time

FAQ

What makes a Bullish Divergence mark print?

Price setting a lower low than at the previous compared pivot while the reading sets a higher one. Both pivots must satisfy the three-bar rule, and the pair has to sit inside the lookback window.

Why does InpPivotRight 3 make a mark land late?

Because a pivot cannot count until the three bars to its right have closed. The turn itself came earlier; the mark simply cannot show up until the shape is complete.

What does InpMinPivotGap 5 keep apart?

Two pivots that sit almost on top of each other. Five bars of space means the check compares two separate swings rather than two halves of the same one.

Where does InpArrowOffsetAtr 0.6 place its arrow?

Six tenths of a fourteen-bar range from the candle on the price chart. Scaling by range rather than points keeps the arrow clear on any symbol without a per-chart adjustment.

Are results guaranteed?

No. Trading involves risk. Results are not guaranteed; past performance is not indicative of future results. Use the Diver Macd Indicator as one input. Always backtest before trading live.

Category: this is part of our Oscillators collection. Also, truly, browse more Oscillators for MetaTrader, or explore every MT4 indicator and MT5 indicator on the site.

External references

Dominic Walsh - Forex trader and MT4/MT5 developer

About the author

Written by Dominic Walsh, a Forex trader and MT4/MT5 indicator, Expert Advisor and script developer. Every tool on forexmt4systems.com is tested on live charts before release and ships with ready-to-use compiled MT4 (.ex4) and MT5 (.ex5) files. Learn more about the trader and developer behind this site.

How we build, test and correct every tool: Editorial & Testing Policy. Trading carries risk; see the disclaimer.

Leave a Comment