Download MetaTrader 5

Divergences Repulse indicator

To add comments, please log in or register
paul
29
paul 2013.11.14 09:51 

Hello,

I use the indicator REPULSE on MT4.
Could you modify the code to identify the divergences ?

thank you very much


//+------------------------------------------------------------------+
//| Repulse.mq4 |
//| FCognet |
//| |
//+------------------------------------------------------------------+
#property copyright "Eric Lefort"
#property link "http://www.pro-at.com"

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_color1 Gray
#property indicator_color2 Yellow
#property indicator_color3 Cyan

//---- input parameters
extern int RepulsePeriod1=1;
extern int RepulsePeriod2=5;
extern int RepulsePeriod3=15;
//---- buffers
double RepulseBuffer1[];
double RepulseBuffer2[];
double RepulseBuffer3[];
double PosBuffer[];
double NegBuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function |
//+------------------------------------------------------------------+
int init() {
string short_name;
short_name="Repulse("+RepulsePeriod1+", "+RepulsePeriod2+", "+RepulsePeriod3+")";
IndicatorShortName(short_name);
//---- indicators
IndicatorBuffers(5);
SetIndexBuffer(0,RepulseBuffer1);
SetIndexBuffer(1,RepulseBuffer2);
SetIndexBuffer(2,RepulseBuffer3);
SetIndexBuffer(3,PosBuffer);
SetIndexBuffer(4,NegBuffer);

SetIndexStyle(0,DRAW_LINE);
SetIndexStyle(1,DRAW_LINE);
SetIndexStyle(2,DRAW_LINE);
SetIndexStyle(3,DRAW_NONE);
SetIndexStyle(4,DRAW_NONE);

SetLevelValue(0,0);
SetLevelStyle(STYLE_DOT,0,DimGray);

//----
return(0);
}

//+------------------------------------------------------------------+
//| iteration function |
//+------------------------------------------------------------------+
int start() {
double forceHaussiere, forceBaissiere;

int index = 0;
int counted_bars=IndicatorCounted();

int limit = Bars - counted_bars;

// Repulse1
for(index=0;index<Bars;index++) {
PosBuffer[index] = ((((3*Close[index])-(2*getLow(index, RepulsePeriod1))-Open[index])/Close[index])*100);
NegBuffer[index] = (((Open[index]+(2*getHigh(index, RepulsePeriod1))-(3*Close[index]))/Close[index])*100);
}
for(index=0;index<limit;index++) {
forceHaussiere=iMAOnArray(PosBuffer, 0, RepulsePeriod1 * 5, 0, MODE_EMA, index);
forceBaissiere=iMAOnArray(NegBuffer, 0, RepulsePeriod1 * 5, 0, MODE_EMA, index);
RepulseBuffer1[index]=forceHaussiere-forceBaissiere;
}

// Repulse2
for(index=0;index<Bars;index++) {
PosBuffer[index] = ((((3*Close[index])-(2*getLow(index, RepulsePeriod2))-Open[index+RepulsePeriod2])/Close[index])*100);
NegBuffer[index] = (((Open[index+RepulsePeriod2]+(2*getHigh(index, RepulsePeriod2))-(3*Close[index]))/Close[index])*100);
}
for(index=0;index<limit;index++) {
forceHaussiere=iMAOnArray(PosBuffer, 0, RepulsePeriod2 * 5, 0, MODE_EMA, index);
forceBaissiere=iMAOnArray(NegBuffer, 0, RepulsePeriod2 * 5, 0, MODE_EMA, index);
RepulseBuffer2[index]=forceHaussiere-forceBaissiere;
}

// Repulse3
for(index=0;index<Bars;index++) {
PosBuffer[index] = ((((3*Close[index])-(2*getLow(index, RepulsePeriod3))-Open[index+RepulsePeriod3])/Close[index])*100);
NegBuffer[index] = (((Open[index+RepulsePeriod3]+(2*getHigh(index, RepulsePeriod3))-(3*Close[index]))/Close[index])*100);
}
for(index=0;index<limit;index++) {
forceHaussiere=iMAOnArray(PosBuffer, 0, RepulsePeriod3 * 5, 0, MODE_EMA, index);
forceBaissiere=iMAOnArray(NegBuffer, 0, RepulsePeriod3 * 5, 0, MODE_EMA, index);
RepulseBuffer3[index]=forceHaussiere-forceBaissiere;
}
return(0);
}

//+------------------------------------------------------------------+
double getLow(int from, int period) {
double low = 9999999999;
for (int index=from; index<=from+period; index++) {
if (low > Low[index]) {
low = Low[index];
}
}
return (low);
}

double getHigh(int from, int period) {
double high = 0;
for (int index=from; index<=from+period; index++) {
if (high < High[index]) {
high = High[index];
}
}
return (high);
} 
Alain Verleyen
Moderator
31090
Alain Verleyen 2013.11.14 10:20  
paul
29
paul 2013.11.14 10:45  

Hi !

I have MT4 not MT5

Tjipke de Vries
6324
Tjipke de Vries 2013.11.14 10:49  
SigFread:

Hi !

I have MT4 not MT5


See Jobs section again
Alain Verleyen
Moderator
31090
Alain Verleyen 2013.11.14 10:51  
SigFread:

Hi !

I have MT4 not MT5

Jobs section is for MT4 and MT5.
Simon Gniadkowski
Moderator
18002
Simon Gniadkowski 2013.11.14 11:18  
SigFread:

Hi !

I have MT4 not MT5

Take a look at the Jobs on the first page, all bar one are for mql4/MT4 . . .
To add comments, please log in or register