by Dr.Hamdi Boukamcha
Author: FX5 (2007.06.05 13:54)
Rating: 48
Downloaded: 20547
FX5_Divergence   FX5_Divergence_V2.0.mq4 (12.2 Kb) View
FX5_Divergence   FX5_Divergence_v1.5.mq4 (14.6 Kb) View
FX5_Divergence   FX5_Divergence_v1.1.mq4 (12.6 Kb) View
FX5_Divergence   FX5_Divergence_V2.1.mq4 (11.3 Kb) View
Divergence is a powerful tool for detecting price reversal points from support and resistance zones. It usually gives us a relatively early signals compared to those given by moving average indicators. It can be successfully applied to many technical indicators and end up with good results.
This indicator will plot divergence lines between the price and OsMA indicator. It will give buy/sell signal according to the type of divergence that was detected. The indicator also is capable of drawing divergence lines for the whole history prices located within a specific chart.


Bullish divergence will be plotted with green lines on both price and OsMA idicator windows.


Bearish divergence will be plotted with red lines on both price and OsMA idicator windows.


I hope this indicator prove to be a useful tool.

Changes to Version 1.5:

  • A bug was fixed in updating divergence lines as the live quotes flow;
  • A sound Alert feature was added to the indicator and can be enabled or disabled from indicator settings;
  • Classical divergence is plotted in Solid Style (continues) lines, while hidden divergence is plotted in Dot Style (interuppted) lines.

Changes to version 2.0:

  • The code was rebuilt from scratch to make the indicator runs much faster.
  • The indicator now doesn’t repaint any of its signals.
  • Some improvements in the signal identification algorithms.

Version 2.1:

  • I attached the last file by mistake. This is the one I wanted to attach. It is the last version. I am designating it version 2.1.


38 comments: 1 2 3 4   To post a new comment, please log in or register

Thank you very much for these excellent divergence indicators. Could you make one that draws regular an hidden divergences for Schaff Trend Cycle?
08.11.2013 00:32 grayghost

How to detect that arrow?

I want to use for ea

and, is there anyone have version 3 at mq4 format?

thank you

[email protected]

13.05.2012 23:14 raden.batman

we need divers only if line up above price and line down lower price

and needs bar’s color depend of previous bar – if previous bar of indi bigger, lower or equal

22.01.2010 14:15 eddy



I modified the code to work with the internal indicators.


03.09.2009 19:55 TheRumpledOne

Hi, FX5.

I can suggest some cosmetic code changes. I think, this may make code a little more readable.

1. In deinit()


       if(StringSubstr(label, 0, 14) != "DivergenceLine")


       if(StringSubstr(label, 0, 14) == "DivergenceLine")


2. In IsIndicatorPeak()


           if(OsMA[i] > OsMA[shift])


           if(OsMA[i] > OsMA[shift])

(and so in IsIndicatorTrough()). 

14.08.2008 12:57 Sajan


Nice and very good Indicator. can you make the same idea for Indicators  Stochastic Momentum and Rsi ?

it will be very powerful maybe in one window?

any way

thank for this one

10.07.2008 20:38 StarLight

Can you make the arrow appear in real time? not like the last bar behind it.
28.05.2008 12:03 Togu

I have questions. I’ve installed the latest fx5 divergence indicators one that repaints and one that doesn’t but I happen to miss the signal all the time. Does the arrow appear after one bar has already closed?

i wanted to SELL on one signal but it appears it only showed just after openning another bar I’ve been monitoring last couple of hours and now I see the arrow. It seems like I’m very late at least one bar or two. Does any1 misses the arrow? Because I’ve been thinking to sell on a signal right after the arrow bar closes.

28.05.2008 12:02 Togu



Could you possibly help by putting the Sendmail function into the indicator for when there is a signal? I tried but my coding ability is less than optimal !! Great indicator….using it to make nice $$$ in futures markets!!!! Maybe a quick explanation of how/when this indicator works? Thanks for sharing your work!!


26.03.2008 19:59 forexman05

is there a chance you could create a code that gives the arrow on the close of the divergence candle.  I find when using this with other indicators it creates some great opportunities

Share this article

Leave a comment