Navigation:Home > Content >

3Color_RVI_Hist.mq4

Time: 2011-09-18 | Download file:3Color_RVI_Hist.mq4

//+------------------------------------------------------------------+
//|                                              3Color_RVI_Hist.mq4 |
//|                              Copyright © 2005, Nikolay Kositsin. |
//|                                                                  |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2005, Nikolay Kositsin ."
#property link      ""

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_level2   0.0
#property indicator_color1 Lime
#property indicator_color2 Red
#property indicator_color3 Purple
//---- input parameters
extern int RVIPeriod = 10;
extern int SignPeriod= 4;
extern int CountBars = 300;
//---- buffers
double ind_buffer1 [];
double ind_buffer2 [];
double ind_buffer3 [];
double RVIBuffer   [];
double SignalBuffer[];
double TempBuffer  [];
double RVI,UpRVI, DownRVI;
//-----------------------------
double value, Oldvalue, minuse;      
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- indicator line
double Color1 = C'128,0,255'; 
   SetIndexStyle(0,DRAW_HISTOGRAM, STYLE_SOLID, 3, Color1); 
   SetIndexStyle(1,DRAW_HISTOGRAM, STYLE_SOLID, 3);
   SetIndexStyle(2,DRAW_HISTOGRAM, STYLE_SOLID, 3);
   SetIndexDrawBegin(0,Bars-CountBars);
   SetIndexDrawBegin(1,Bars-CountBars); 
   SetIndexDrawBegin(2,Bars-CountBars);

//---- 6 additional buffers are used for counting.
   IndicatorBuffers(6);
   SetIndexBuffer(0, ind_buffer1 );
   SetIndexBuffer(1, ind_buffer2 );
   SetIndexBuffer(2, ind_buffer3 );
   SetIndexBuffer(3, TempBuffer  ); 
   SetIndexBuffer(4, RVIBuffer   );
   SetIndexBuffer(5, SignalBuffer);  
//---- name for DataWindow and indicator subwindow label
   short_name="RVI("+RVIPeriod+")";
   IndicatorShortName(short_name);
   SetIndexLabel(0,"RVI_UP");
   SetIndexLabel(1,"RVI_DOWN");
   SetIndexLabel(2,"RVI_Stright");
//----
   SetIndexEmptyValue(0,0);
   SetIndexEmptyValue(1,0);
   SetIndexEmptyValue(2,0);
 //----
 
   return(0);
  }
//+------------------------------------------------------------------+
//| Relative Vigor Index                                          |
//+------------------------------------------------------------------+
 int start()
     {
   int limit;
   int counted_bars=IndicatorCounted();
//---- check for possible errors
   if(counted_bars<0) return(-1);
   if(Bars<=RVIPeriod) return(0); 
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
   
//--------RVI_Hist-----------------------------------------------------------------------------------------------------=  
  
   for(int i=0; i0.0)ind_buffer1[k]= value; else {if(minuse<0.0) ind_buffer2[k]= value; else ind_buffer3[k]= value;} 
       
     
       }    
 //--------------------------------------------------------------------------------------------------------------------+
      
   return(0);
     }
//+---------------------------------------------------------------------------------------+ 

Recommend