
You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
Here is the code for an indicator that helps find divergent candles. Turns the Bullish ones Gree and the Bear ones Red. However, its for MT3. Could I just put it in to MT4 and Compile it? Dont want to try cause it might cause a glitch in my platform. So I thought I better ask first.
/*[[
Name := Wiseman 1
Author := David Thomas, Basileus@Moneytec
Notes := Bill Williams Wiseman 1 Divergent bars. ver. 3.
Notes := the changes of Basileus@Moneytec have been corrected and simplified.
Separate Window := No
First Color := LimeGreen
First Draw Type := Histogram
First Symbol := 217
Use Second Data := Yes
Second Color := Red
Second Draw Type := Histogram
Second Symbol := 218
]]*/
Variables : shift(0), prevbars(0), first(True), lips(0), teeth(0), loopbegin(0), median(0), jaws(0), result(0);
SetLoopCount(0);
// check conditions are ok.
if Bars < 3 Or Bars = prevbars then exit;
// check for additional bars loading or total reloading
If Bars 1 Then first = True;
prevbars = Bars;
If first Then Begin
// loopbegin prevent counting of counted bars exclude current
loopbegin = Bars-2;
first = False;
End;
// loop from first bar to current bar (with shift=0)
For shift=Bars-5 Downto 0 Begin
result = 0;
median = (H[shift]+L[shift])/2;
lips = iAlligator(13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORLIPS, shift);
teeth = iAlligator(13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORTEETH, shift);
jaws = iAlligator(13, 8, 8, 5, 5, 3, MODE_SMMA, PRICE_MEDIAN, MODE_GATORJAW, shift);
// test for bullish divergent bar:
if ((C[shift] >= median) // close is in lower half of bar
and (H[shift] < Min(Min(lips,teeth),jaws)) // bar is completely below alligator
and (L[shift] < L[shift+1]) and (L[shift] < L[shift+2]) // low is moving down
and (L[shift] < L[shift+3]) and (L[shift] < L[shift+4]) // ...
and (iAO(shift) < iAO(shift+1)) // checking if it's right AO signal
) then result = 1;
// test for bearish divergent bar:
if ((C[shift] <= median) // close is upper half of bar
and (L[shift] > Max(Max(lips,teeth),jaws)) // bar is completely above alligator
and (H[shift] > H[shift+1]) and (H[shift] > H[shift+2]) // high is moving up
and (H[shift] > H[shift+3]) and (H[shift] > H[shift+4]) // ...
and (iAO(shift) > iAO(shift+1)) // checking if it's right AO signal
) then result = -1;
if result < 0 then
{
// red bar.
SetIndexValue(shift, Low[shift]);
SetIndexValue2(shift, High[shift]);
}
if result > 0 then
{
// green bar.
SetIndexValue(shift, High[shift]);
SetIndexValue2(shift, Low[shift]);
}
End;