Navigation´╝ÜHome > Content >

TD_REI.mq4

Time: 2012-07-06 | Download file:TD_REI.mq4

//+------------------------------------------------------------------+ 
//| REI.mq4 | 
//| Mishutka | 
//| www.ourarsenal.narod.ru | 
//+------------------------------------------------------------------+ 
#property copyright "Mishutka" 
#property link "www.ourarsenal.narod.ru" 

#property indicator_separate_window 
#property indicator_buffers 1 
#property indicator_color1 Red 
//+------------------------------------------------------------------+ 
//| Custom indicator initialization function | 
//+------------------------------------------------------------------+ 
extern int lenght=8; 
extern int NBars=100; 
double REABS[21]; 
double RE[21]; 
double REI; 
double SUM; 
double SUMABS; 
int Z; 
double TDREI; 

double WORK[]; 
int init() 
{ 
REI=0; 
SUM=0; 
SUMABS=0; 
Z=0; 
TDREI=0; 
int www=14; 

IndicatorBuffers(1); 
SetIndexBuffer(0,WORK); 
//---- drawing settings 
SetIndexLabel(0,"REI"); 
//SetIndexDrawBegin(0,0); 
//SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,255); 
SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,1); 

IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1); 
//---- indicator buffers mapping 


//---- name for DataWindow and indicator subwindow label 


//---- initialization done 
return(0); 
} 
int start() 
{ 
Sleep(100); 
int counted_bars=IndicatorCounted(); 
int limit; 
//---- check for possible errors 
if(counted_bars<0) return(-1); 
//---- last counted bar will be recounted 
if(counted_bars>0) counted_bars--; 
limit=Bars-counted_bars; 

//---- rei counted in the 1-st buffer 
//??? ????? ? ????????? ??????? ???????? ? ??????? ? ???????????? ???? ? ?????????? ? ????????? ?? ??? ??? ?? ?????. 
//????????????? ???????? ??????????? ?????, ????? ???????????? ???? ????, ??? ??? ??? ?????. ????????????? ???????? 
// ??????????? ?????, ????? ??? ???????????? ???? ??????, ??? ??? ??? ?????. ???? ??????????? ???? ???? ??????????? 
//???? ??? ??? ???? ?????, ?? ??????????? ????????????? ????????. ???? ??? ??????, ??? ??? ??? ?????, ?? ??????????? ? 
//???????????? ????????. ????? ??? ?????????? ???????? ??????????? ? ???????????? ???????? ??? ??????? ???. 



for (int shift=limit;shift>=0;shift--) 
{ 

RE[0]=(High[shift]-High[shift+2])+(Low[shift]-Low[shift+2]); 
REABS[0]=MathAbs(High[shift]-High[shift+2])+MathAbs(Low[shift]-Low[shift+2]); 
SUM=0; 
SUMABS=0; 

for (Z=0;Z<=lenght-1;Z++) 
{ 
SUM=SUM+RE[Z]; 
SUMABS=SUMABS+REABS[Z]; 
} 

if (SUMABS>0) {REI=SUM/SUMABS;} 

TDREI=100*REI; 
if (TDREI==0) {TDREI=0.00001;} 



WORK[shift]=TDREI; 


for (Z=21;Z>=0;Z--) 
{ 
RE[Z]=RE[Z-1]; 
REABS[Z]=REABS[Z-1]; 
} 

} 


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

Recommend