Loading…

MACD With Divergence

The MACD lines here are the standard calculation, read straight off the built-in indicator so the values match whatever plain MACD is already on the chart - nothing about the oscillator itself is reinvented. What is added is a divergence marker, and it is built on a strict rule rather than a visual "looks like it" judgement. A swing high or low only counts once it is a confirmed fractal - the highest or lowest point within K bars on both sides, which by definition cannot be known until those K bars have closed. Divergence is then a straight comparison between two confirmed swings of the same type: bearish when price's second swing high is higher than its first but MACD's reading at that second high is lower than at the first; bullish is the mirror case on swing lows. Because both swings being compared are already confirmed by the time the marker can appear, the marker itself never moves once drawn and never appears retroactively on a bar that has already scrolled off the right edge of the chart. What it costs is a lag of K bars behind the live edge, which is the same lag every fractal-based tool in this catalogue carries and the price of not repainting. Notes and limitations - Divergence here means regular divergence only (price extreme not confirmed by the oscillator) - it does not attempt to classify hidden divergence, which is a different and more ambiguous read. - Every marker sits InpK bars behind the live edge by construction; treat it as confirmation of a completed structural disagreement, not a same-bar entry trigger. - Divergence is a warning sign, not a trade signal on its own - price can and does keep extending after a confirmed divergence, sometimes for a long time. Combine with the trader's own trigger and risk management. - Uses the built-in iMACD() call for the lines themselves rather than a hand-rolled EMA calculation, so warm-up behaviour matches the platform's own MACD exactly.

Indicator · MT5 · v1.0 · Free

About MACD With Divergence

MACD With Divergence is an indicator for MetaTrader 5 based on Divergence and MACD. It draws buy and sell arrows on the chart and can alert you with a pop-up, sound, email or push message. It has 6 settings, such as Fast ema, Slow ema and Signal ema. MQL source code included.

Files in the download: MacdDivergence.ex5, MacdDivergence.mq5, MacdDivergence.txt.

Settings

SettingDefaultWhat it does
Fast ema12Fast EMA period
Slow ema26Slow EMA period
Signal ema9Signal EMA period
Applied pricePRICE_CLOSEApplied price
K3Bars required on each side to confirm a swing
AlertstrueAlert on a new confirmed divergence

How to install

  1. Download the ZIP from your PolyMaria library and unzip it.
  2. In MetaTrader 5 open File → Open Data Folder, then go to MQL5 → Indicators.
  3. Copy the .mq5 file(s) there. Put any .mqh files in MQL5 → Include.
  4. Open the .mq5 file in MetaEditor and press Compile (F7) if MetaTrader does not show it.
  5. Drag the indicator from the Navigator onto a chart and adjust the settings.

Download the PDF guide

Tags: MACD · Divergence · Fractals · Oscillator · Buy/Sell Arrows · Alerts · MT5 Indicator · MQL5 Source Code

MetaTrader 4 & 5 indicators · PolyMaria