Select Language

【MT4/MT5】MACD Divergence Indicator

  • Overview
  • How to install
  • How to set up
search

Display:

Technical Sub-chart
MT4 MT5

download download download

This indicator detects regular and hidden divergences between price and the MACD line or histogram and highlights them with lines, arrows, and labels to help identify potential entry opportunities.

download
Download for MT4 (Vr. 1.00)
download
Download for MT5 (Vr. 1.00)

download download download

ComingSoon
eaChart
eaChart
eaChart

Feature: MACD divergence detection

Display the MACD line, signal line, histogram, and zero line

It calculates the MACD internally and displays the MACD line, signal line, histogram, and zero line together in the MACD subwindow. There is no need to apply MT4/MT5's built-in MACD separately to the chart. You can individually show or hide each element, as well as customize their colors and widths to suit your preferences.

Basic MACD subwindow view Basic MACD subwindow view

Detects regular and hidden divergences

By comparing price highs and lows with those of the MACD line or histogram, this indicator detects regular and hidden divergences, which can indicate potential trend reversals and continuations, respectively. Divergences are highlighted with lines on both the main chart and MACD subwindow, with arrows and labels additionally displayed only in the subwindow. The divergence type can be selected as regular, hidden, or both in the Divergence Mode parameter.

Regular and hidden divergence example Regular and hidden divergence example

Find divergences near the zero line

The Zero Line Filter only displays divergences that occur when the MACD is near the zero line. With Zero Filter Pivot Mode, you can choose whether both pivots or either pivot must meet the criteria, allowing you to adjust signal frequency and accuracy.

Zero Line Filter applied Zero Line Filter applied

Focus on potential trend continuations with the Trend Filter

The Trend Filter only displays hidden divergences that occur in upward or downward trends, based on the selected Trend Filter Mode. Since regular divergences are excluded, you can focus on trend continuation signals.

Trend Filter applied Trend Filter applied

Select MACD line or histogram for divergence detection

Choose the data used for divergence detection from MACD line highs/lows, MACD histogram peaks/troughs, or both. When both are selected, duplicate signals are combined into the MACD line signals for a cleaner view.

Choosing a divergence source

Never miss a divergence with alerts

Receive pop-up, push, or email notifications when new divergences are identified. You can stay on top of potential reversals and continuations without constantly watching the charts.

Alert example
caution Important notes
Divergences detected by this indicator do not guarantee trend reversals or continuations. No automated trading or order placement is supported. On the main chart, only divergence lines are displayed, without labels or arrows. The divergence type can be checked in the MACD subwindow.
How to install
How to set up

How to install

To use MACD Divergence Indicator, install the "[Myforex] MACD Divergence Indicator" file on MetaTrader4 (MT4) / MetaTrader5 (MT5).

Step 1

Click "File" from the menu bar at the top of MT4/MT5 and choose "Open Data Folder".

Open data folder

Step 2

After opening the data folder, double-click the folder "MQL5 (MQL4 for MT4)" in it to open it.

Open MQL5 folder

Step 3

Double-click to open the "Indicators" folder in the MQL5 folder.

Open Indicators folder

Step 4

Save the "[Myforex] MACD Divergence Indicator" in the "Indicators" folder.

Save indicator

Step 5

Once the file is in the folder, right-click "Indicators" in the Navigator and choose "Refresh" from the displayed menu.

Refresh Indicator

Step 6

After checking that MACD Divergence Indicator is shown in the "Indicators" of the Navigator, apply it to a chart by double-clicking or dragging and dropping.

If you can't see the Navigator window, Go to the menu bar and select "View" → "Navigator". Alternatively, press Ctrl+N to show or hide the Navigator window.

Apply the MACD Divergence Indicator Apply the MACD Divergence Indicator

Step 7

Refer to the "How to set up" page to make further settings in the "Inputs" tab, then click "OK".

If the indicator can't be added to a chart, Verify that the indicator is saved in the Indicators folder and that the file name has not been changed. If it still doesn't appear after refreshing the Navigator window, restart MT5 and try again.

Overview
How to set up

How to set up

After applying the indicator to the chart, set the parameters according to your style.

Step 1

First, open the "Inputs" tab.

Open Inputs tab

Step 2

Set the parameters as follows.

General Settings

Item name Description
Divergence Mode Choose divergence types to detect: regular, hidden or both.
Divergence Source Choose the source to use for divergence detection: MACD line, histogram, or both.
Fast EMA Period Set the short-term EMA period used to calculate MACD.
Slow EMA Period Set the long-term EMA period used to calculate MACD.
Signal Period Set the period used to calculate the signal line.
Applied Price Select the price type used for MACD calculation.
Pivot Left Bars Set the number of bars to the left of a high/low used to identify pivots.
Pivot Right Bars Set the number of bars to the right of a high/low used to identify pivots.
Min Pivot Distance Sets the minimum bar distance between two pivots to detect a divergence.
Max Pivot Distance Sets the maximum bar distance between two pivots to detect a divergence.
Pivot Match Tolerance Set the maximum number of bars allowed between matching price and MACD pivots.
Use Confirmed Pivot Enable this option to use only confirmed pivots, reducing fluctuations from unconfirmed price movements.
Signal Interval Set the minimum number of bars between signals of the same direction.
Max Search Bars Set the maximum number of bars to search for divergences.
Divergence Mode
Choose divergence types to detect: regular, hidden or both.
Divergence Source
Choose the source to use for divergence detection: MACD line, histogram, or both.
Fast EMA Period
Set the short-term EMA period used to calculate MACD.
Slow EMA Period
Set the long-term EMA period used to calculate MACD.
Signal Period
Set the period used to calculate the signal line.
Applied Price
Select the price type used for MACD calculation.
Pivot Left Bars
Set the number of bars to the left of a high/low used to identify pivots.
Pivot Right Bars
Set the number of bars to the right of a high/low used to identify pivots.
Min Pivot Distance
Sets the minimum bar distance between two pivots to detect a divergence.
Max Pivot Distance
Sets the maximum bar distance between two pivots to detect a divergence.
Pivot Match Tolerance
Set the maximum number of bars allowed between matching price and MACD pivots.
Use Confirmed Pivot
Enable this option to use only confirmed pivots, reducing fluctuations from unconfirmed price movements.
Signal Interval
Set the minimum number of bars between signals of the same direction.
Max Search Bars
Set the maximum number of bars to search for divergences.

Zero Filter Settings

Item name Description
Zero Line Margin Mode Choose a fixed value or automatic calculation for the range considered near the zero line.
Zero Filter Pivot Mode Choose whether the Zero Line Filter requires both pivots or either pivot to meet the condition.
Zero Line Margin Set the range considered near the zero line when the fixed value mode is selected.
Zero Line Margin Percent Set the percentage to use when the automatic calculation mode is selected.
Zero Line Auto Lookback Set the number of bars used to calculate the recent MACD range for zero line margin.
Zero Line Margin Mode
Choose a fixed value or automatic calculation for the range considered near the zero line.
Zero Filter Pivot Mode
Choose whether the Zero Line Filter requires both pivots or either pivot to meet the condition.
Zero Line Margin
Set the range considered near the zero line when the fixed value mode is selected.
Zero Line Margin Percent
Set the percentage to use when the automatic calculation mode is selected.
Zero Line Auto Lookback
Set the number of bars used to calculate the recent MACD range for zero line margin.

Trend Filter Settings

Item name Description
Trend Filter Mode Select the method used to identify upward and downward trends for the Trend Filter.
Trend MA Period Set the MA period used to identify the trend.
Trend MA Method Set the MA type used to identify the trend.
Trend MA Applied Price Set the price type used to identify the trend.
Trend Slope Lookback Set the number of bars to check the MA slope.
Trend Filter Mode
Select the method used to identify upward and downward trends for the Trend Filter.
Trend MA Period
Set the MA period used to identify the trend.
Trend MA Method
Set the MA type used to identify the trend.
Trend MA Applied Price
Set the price type used to identify the trend.
Trend Slope Lookback
Set the number of bars to check the MA slope.

Display Settings

Item name Description
Show Price Divergence Lines Display divergence lines in the main chart.
Show MACD Line Display the MACD line in the MACD subwindow.
Show Signal Line Display the signal line in the MACD subwindow.
Show Histogram Display the histogram in the MACD subwindow.
Show Zero Line Display the zero line in the MACD subwindow.
Show MACD Divergence Lines Display the divergence lines in the MACD subwindow.
Show Arrows Display arrows at divergence points.
Show Labels Display labels indicating the divergence type.
Max MACD Display Bars Set the maximum number of bars for the MACD line, signal line, and histogram.
Max Signals Per Type Set the maximum number of signals to display, counting from the latest.
Label Font Size Set the divergence label font size.
Arrow Offset Rate Set the divergence arrow offset as a percentage.
Show Price Divergence Lines
Display divergence lines in the main chart.
Show MACD Line
Display the MACD line in the MACD subwindow.
Show Signal Line
Display the signal line in the MACD subwindow.
Show Histogram
Display the histogram in the MACD subwindow.
Show Zero Line
Display the zero line in the MACD subwindow.
Show MACD Divergence Lines
Display the divergence lines in the MACD subwindow.
Show Arrows
Display arrows at divergence points.
Show Labels
Display labels indicating the divergence type.
Max MACD Display Bars
Set the maximum number of bars for the MACD line, signal line, and histogram.
Max Signals Per Type
Set the maximum number of signals to display, counting from the latest.
Label Font Size
Set the divergence label font size.
Arrow Offset Rate
Set the divergence arrow offset as a percentage.

Max Label Count is omitted from this table as it exists for compatibility and future use and does not affect the display. Use Max Signals Per Type instead.

Color Settings

Item name Description
MACD Line Color Set the MACD line color.
Signal Line Color Set the signal line color.
Histogram Positive Expanding Color Set the color used when the histogram is expanding in the positive range.
Histogram Positive Shrinking Color Set the color used when the histogram is shrinking in the positive range.
Histogram Negative Expanding Color Set the color used when the histogram is expanding in the negative range.
Histogram Negative Shrinking Color Set the color used when the histogram is shrinking in the negative range.
Zero Line Color Set the zero line color.
Bull Regular Color Set the color of lines, arrows and labels for bullish regular divergences.
Bear Regular Color Set the color of lines, arrows and labels for bearish regular divergences.
Bull Hidden Color Set the color of lines, arrows and labels for bullish hidden divergences.
Bear Hidden Color Set the color of lines, arrows and labels for bearish hidden divergences.
Bull Zero Filter Color Set the color of bullish divergences when the zero line filter is applied.
Bear Zero Filter Color Set the color of bearish divergences when the zero line filter is applied.
Bull Hidden Zero Filter Color Set the color of bullish hidden divergences when the zero line filter is applied.
Bear Hidden Zero Filter Color Set the color of bearish hidden divergences when the zero line filter is applied.
Bull Trend Hidden Color Set the color of bullish hidden divergences when the trend filter is applied.
Bear Trend Hidden Color Set the color of bearish hidden divergences when the trend filter is applied.
MACD Line Color
Set the MACD line color.
Signal Line Color
Set the signal line color.
Histogram Positive Expanding Color
Set the color used when the histogram is expanding in the positive range.
Histogram Positive Shrinking Color
Set the color used when the histogram is shrinking in the positive range.
Histogram Negative Expanding Color
Set the color used when the histogram is expanding in the negative range.
Histogram Negative Shrinking Color
Set the color used when the histogram is shrinking in the negative range.
Zero Line Color
Set the zero line color.
Bull Regular Color
Set the color of lines, arrows and labels for bullish regular divergences.
Bear Regular Color
Set the color of lines, arrows and labels for bearish regular divergences.
Bull Hidden Color
Set the color of lines, arrows and labels for bullish hidden divergences.
Bear Hidden Color
Set the color of lines, arrows and labels for bearish hidden divergences.
Bull Zero Filter Color
Set the color of bullish divergences when the zero line filter is applied.
Bear Zero Filter Color
Set the color of bearish divergences when the zero line filter is applied.
Bull Hidden Zero Filter Color
Set the color of bullish hidden divergences when the zero line filter is applied.
Bear Hidden Zero Filter Color
Set the color of bearish hidden divergences when the zero line filter is applied.
Bull Trend Hidden Color
Set the color of bullish hidden divergences when the trend filter is applied.
Bear Trend Hidden Color
Set the color of bearish hidden divergences when the trend filter is applied.

Line Settings

Item name Description
MACD Line Width Set the MACD line width.
Signal Line Width Set the signal line width.
Histogram Width Set the histogram bar width.
Divergence Line Width Set the width of divergence lines in the MACD subwindow.
Divergence Line Style Set the type of divergence lines (e.g., solid, dotted) in the MACD subwindow.
Arrow size Set the arrow size used to signal divergences.
MACD Line Width
Set the MACD line width.
Signal Line Width
Set the signal line width.
Histogram Width
Set the histogram bar width.
Divergence Line Width
Set the width of divergence lines in the MACD subwindow.
Divergence Line Style
Set the type of divergence lines (e.g., solid, dotted) in the MACD subwindow.
Arrow size
Set the arrow size used to signal divergences.

Alert Settings

Item name Description
Enable Pop-up Alert Enable this option to receive pop-up notifications when a divergence is confirmed.
Enable Push Notification Enable this option to receive push notifications when a divergence is confirmed. Set up your MetaQuotes ID in MT4/MT5 first.
Enable Email Notification Enable this option to receive emails when a divergence is confirmed. MT4/5 email settings must be configured first.
Enable Pop-up Alert
Enable this option to receive pop-up notifications when a divergence is confirmed.
Enable Push Notification
Enable this option to receive push notifications when a divergence is confirmed. Set up your MetaQuotes ID in MT4/MT5 first.
Enable Email Notification
Enable this option to receive emails when a divergence is confirmed. MT4/5 email settings must be configured first.
Overview
How to install

Date

Created

 : 2026.09.11

Update

Last updated

 : 2026.09.16


Disclaimer:arw

All information and content provided on this website is provided for informational purposes only and is not intended to solicit any investment. Although all efforts are made in order to ensure that the information is correct, no guarantee is provided for the accuracy of any content on this website. Any decision made shall be the responsibility of the investor and Myforex does not take any responsibility whatsoever regarding the use of any information provided herein.

The copyright in our content belongs to us.

We welcome your use of our content within appropriate limits, including use through our sharing features, sharing on social media, and quotation. However, please refrain from unauthorized reuse, including but not limited to commercial use, reproduction with modification of content, or reproduction on websites that compete with us. We may take necessary measures, including but not limited to deletion of the relevant content, if we consider that the content has been used in an inappropriate or unauthorized manner.

  • Facebook
  • Twitter
  • LINE

Myforex uses cookies to improve the convenience and functionality of this website. This website may include cookies not only by us but also by third parties (advertisers, log analysts, etc.) for the purpose of tracking the activities of users. Cookie policy

I agree
share
Share
Cancel
Not logged in
close

To download the indicator, you need to login to your Myforex member account.

Please login and try again.