MQL4 - automated forex trading   /  

Code Base

ODL Securities

Code Base  Indicators  FX5_MACD_Divergence To post a new code, please log in or register

This library is for
MetaTrader 4
Download MT4 - 3.5 Mb

Mobile trading!
Buy a license and be mobile in your trading!

Name:
FX5_MACD_Divergence
Author: FX5 (2007.06.14 11:29)
Rating: 8.8
Downloaded: 9770
Download:
 FX5_MACD_Divergence_V1.1.mq4 (12.4 Kb) View
 FX5_MACD_Divergence_V1.0.mq4 (12.1 Kb) View


After the success of the original indicator, I decided to write more indicators for detecting divergence between price and other indicator.



This indicator will plot divergence lines on the MACD indicator and will give buy and sell signal by displaying green and red arrows. It also has a built-in alert function. As the original indicator, bullish divergence is plotted in green lines while bearish divergence is plotted in red. If the divergence is classic the line will be solid and if the type is reversed the line will be interrupted.



I hope you gets the most benedfit from this indicator.

Changes to verion 1.1:

- This version is directed to traders who do not want repainted singals. The signals are not repainted buy they are delayed one candle.

 

14 comments: 1 2   To post a new comment, please, log in or register

Hi FX5,

good work! I looked an Indikator like these for long time.

If you take DMI (Directional Movement ) the result are very better. This is a concept from Welles Wilder, named "Topsy-turvy-Strategy"

and based of reverse Divergenz

His book: New Concepts in Technical Trading Systems

Can you build an Indicator with DMI and "reverse Divergenc"?

Best regards

Meta1  

 

 

17.08.2008 16:28 Meta1

Thank you for this indicator.

A little bit oof topic:

I have would like to translate the Ehlers sinewave from Tradestation language to MQL4 ... but I do not know the language well enough.

'Ehlers sinewave indicator translation into MQL4'

Would you be interested in coding this in MQL4?

Thanks !

----------------------------------------------

Inputs: Price((H+L)/2),
alpha(.07);

Vars: Smooth(0),
Cycle(0),
I1(0),
Q1(0),
I2(0),
Q2(0),
Deltaphase(0),
MedianDelta(0),
Maxhmp(0),
AmpFix(0),
Re(0),
Im(0),
DC(0),
alpha1(0),
InstPeriod(0),
DCPeriod(0),
count(0),
Smoothcycle(0),
Realpart(0),
Imagpart(0),
DCPhase(0);

smooth = (Price + 2*Price[1] + 2*Price[2] + Price[3])/6;

Cycle = (1 - .5*alpha)*(1 - .5*alpha)*(Smooth - 2*Smooth[1] + Smooth[2]) + 2*(1 - alpha)*Cycle[1] - (1 - alpha)*(1 - alpha)*Cycle[2];
If currentbar < 7 then Cycle = (Price - 2*Price[1] + Price[2]) / 4;
{Cycle = Price;}

Q1 = (.0962*Cycle + .5769*Cycle[2] - .5769*Cycle[4] - .0962*Cycle[6])*(.5 + .08*InstPeriod[1]);
I1 = Cycle[3];
If Q1 <> 0 and Q1[1] <> O then Deltaphase = (I1/Q1 - I1[1]/Q1[1]) / (1 + I1*I1[1]/(Q1*Q1[1]));

If Deltaphase < 0.1 then Deltaphase = 0.1;
If Deltaphase > 1.1 then Deltaphase = 1.1;
MedianDelta = Median(Deltaphase, 5);
If MedianDelta = 0 then DC = 15 else DC = 6.28318/MedianDelta + .5;
InstPeriod = .33*DC + .67*InstPeriod[1];
Value1 = .15*InstPeriod + .85*Value1[1];

{Compute Dominant Cycle Phase}
DcPeriod = IntPortion(value1);
RealPart = 0:
ImagPart = 0;
For count = 0 To DcPeriod - 1 begin
RealPart = RealPart + Sine(360 * count/DcPeriod) * (Cycle[count]);
ImagPart = ImagPart + Cosine(360 * count/DcPeriod) * (Cycle[count]);
End;
If AbsValue(ImagPart) > 0.001 then DcPhase = Arctangent(RealPart / ImagPart);
If AbsValue(ImagPart) <= 0.001 then DcPhase = 90 * Sign(RealPart);
DcPhase = DcPhase + 90:
If ImagPart < 0 then DcPhase = DcPhase + 180;
If Dcphase > 315 then DcPhase = DcPhase - 360;
Plot1(Sine(DcPhase), "Sine");
Plot1(Sine(Dcphase + 45), "LeadSine");

02.02.2008 15:31 marcb
vladv wrote:
It's a good indicator!

Thanks vladv.
17.08.2007 21:52 FX5
It's a good indicator!
17.08.2007 13:06 vladv
ashishbhatia wrote:
hi...i am using the indicator for sometime now, could you tell me which timeframe its best used on, i check all the timeframes, but find 5 mins comfortable. Also, there are some hidden signals given, which are not the classic MACD divergence, how relaible are those, would apprectiate your reply.
thanks


I prefer using it on higher timeframes. In my openion 4Hr is the best timeframe for this indicator.

Regarding your second question, I heard that some traders trade only hidden divergens so it reliable as the classical divergence.

Good Luck,

15.08.2007 22:41 FX5
hi...i am using the indicator for sometime now, could you tell me which timeframe its best used on, i check all the timeframes, but find 5 mins comfortable. Also, there are some hidden signals given, which are not the classic MACD divergence, how relaible are those, would apprectiate your reply.
thanks
14.08.2007 20:38 ashishbhatia

"Changes to verion 1.1: This version is directed to traders who do not want repainted singals. The signals are not repainted buy they are delayed one candle. "

Is it not possible to have a version which has the best best of both worlds? I.e. One that doesn't repaint, whilst not being delayed by a candle.

Thanks.
15.06.2007 23:27 fx_geezer
Okay, you got me there. It was too late when i looked at the results I guess ;) But finally I decided to stick to the histogram version so I made the needed corrections. Thanks for replying and posting these indicators! They are very very useful!
14.06.2007 17:45 SnaiPear
SnaiPear wrote:
FX5: I don't know then what it's called, but thake a look at this screenshot! It's the simple "MACD" indicator from the indicators list of MT4.
I compared the signals and they are not the same on your version and this what I call "oscillator".

The indicator in you chart is the regular MACD, which is used in my indicator. The diffirance is in shape only. My indicator plots MACD as a line instead of the histogram in your chart.

If you are more comportable with the histogram, you can modify the code to change how do you want MACD to appear.

Change the following code:

   SetIndexStyle(2, DRAW_LINE);

to:

   SetIndexStyle(2, DRAW_HISTOGRAM);

and you will have it done :-)

14.06.2007 17:10 FX5
FX5: I don't know then what it's called, but thake a look at this screenshot! It's the simple "MACD" indicator from the indicators list of MT4.
I compared the signals and they are not the same on your version and this what I call "oscillator".
14.06.2007 11:31 SnaiPear