Divergence Detection Indicator for MT4/MT5
Info
The Divergence Detection Indicator for MT4/MT5 is a Indicator for MetaTrader 4 that this indicator visually displays divergences using two matched lines: one on the price chart and another on the indicator chart. It supports the detection of four types of divergences.
Usage
This tool is typically used for enhancing chart analysis and decision making.
Platform
This Indicator works exclusively on MetaTrader 4 (both build 600+ and newer versions).
Setup
Place the downloaded file in MQL4/Indicators folder via File ? Open Data Folder in MetaTrader 4.
How to Install and Use Divergence Detection Indicator for MT4/MT5
1. Installation: Place your file in the MQL/Indicators folder via "Open Data Folder" and restart your terminal.
2. Loading: Find the indicator in the Navigator, drag it onto your chart, and configure the input parameters in the popup window.
3. Customization: Press Ctrl+I to open the indicator list, select your tool, and click "Properties" to change colors, levels, or visual styles.
4. Updating: Replace the old file in the Indicators folder with the new version and restart the platform to apply changes.
Frequently Asked Questions
Q: Why is my indicator not showing? A: Verify the file is in the MQL/Indicators folder, or try right-clicking the "Indicators" tree in the Navigator and clicking "Refresh."
Q: Do custom indicators slow down the platform? A: Too many complex indicators can impact performance; remove unused ones via the "Indicator List" (Ctrl+I).
Q: Can I use MT4 indicators on MT5? A: No, MQL4 and MQL5 are distinct languages; ensure the indicator is compiled specifically for your platform version.
What this tool does
This indicator visually displays divergences using two matched lines: one on the price chart and another on the indicator chart.
Typical Use Case
This Indicator excels in automated trading and technical analysis on MetaTrader 4.
Compatible Platform & Setup
This Indicator works on MetaTrader 4. Place the file in the MQL4/Indicators folder and restart the terminal.
Description & Settings
Related: Divergence Indicator Panel - another powerful indicator for MetaTrader 4 traders.
This indicator visually displays divergences using two matched lines: one on the price chart and another on the indicator chart.Also recommended: Multi-Indicator Divergence Detector for MetaTrader 4 - similar indicator with strong performance on MetaTrader 4.
It supports the detection of four types of divergences.For each divergence type, you can enable or disable its display and select the color for bullish and bearish divergence lines.
The indicator can utilize one of six standard MetaTrader indicators (RSI, MACD, Momentum, RVI, Stochastic, Standard Deviation) as the source for divergence detection with price. This is referred to as the 'base indicator'.
Additionally, it supports two custom indicators: Derivative and William Blau.
Base Indicator Settings:
The parameters for the base indicator are configured in the 'base indicator' input block.
Parameters should be entered in the same order as they appear in the standard indicator.
For example, with the Stochastic indicator, the mapping is as follows:
'First calculation period' corresponds to %K.
'Second calculation period' corresponds to %D.
'Third calculation period' corresponds to the slowing period.
If a base indicator has fewer than three parameters, the excess period settings will be ignored.
For RSI and Momentum, only 'First calculation period' and 'Indicator calculation price' are needed.
Custom Indicator Settings:
If you wish to use a different indicator as the base indicator, select 'Custom' in the 'Base indicator' parameter.
Then, configure the 'Custom indicator' block:
'Indicator name': The name of the indicator as it appears in the MetaTrader 'Navigator' window (without the file extension).
'Index of the buffer for data pickup': The index of the indicator line to use for plotting the base indicator chart (typically 0).
'Number of the indicator parameters': The count of input parameters the custom indicator uses. Setting this to 0 will use the indicator's default parameters.
'Value of the N-th parameter': Set the specific values for the custom indicator's parameters.
Divergence Detection Parameters:
After configuring the base indicator, set the 'Depth of the 2nd support point lookup' to determine the maximum lookback period for divergences.
Set the 'From price extremum to indicator extremum' to define how closely price and indicator extremums must align.
Divergence Registration Logic:
The indicator identifies divergences by detecting local extremums. An extremum requires at least three bars, with the middle bar being the peak or trough.
Consequently, divergence registration occurs with a two-bar delay.
The indicator displays class A divergences and highlights relevant bars with vertical lines.
For a comprehensive explanation of the indicator's capabilities and logic, please refer to the dedicated article, updated for 2026.
You may also like: moving average convergence divergence (macd) - excellent alternative for indicator users on MetaTrader 4.
Source Code
#property copyright "robotfx"
#property link "https://robotfx.org"
#property description "this code is educational. feel free to use, modify and upgrade as you wish. visit robotfx.org for professional trading tools"
#property version "1.18"
#property strict
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 clrdodgerblue
#property indicator_level1 0.0
enum enum_yesno
.......
⚠ Limitations & Risk Warning
- This tool is provided for educational and testing purposes only.
- Past performance does not guarantee future results.
- Trading involves substantial risk of loss. Use on a demo account first.
- Results may vary depending on market conditions, broker, and settings.
- We recommend thorough backtesting and forward testing before using with real funds.