Navigation´╝ÜHome > Content >

CCI_Woodies_[i].mq4

Time: 2011-06-09 | Download file:CCI_Woodies_[i].mq4

//+------------------------------------------------------------------+
//|                                                  CCI_Woodies.mq4 |
//|                                                                  |
//|                                                                  |
//+------------------------------------------------------------------+

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 SteelBlue
#property indicator_color2 Red
//---- input parameters
extern int CCIPeriod1=14;
extern int CCIPeriod2=6;
//---- buffers
double CCIBuffer1[];
double CCIBuffer2[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   string short_name;
//---- indicator line
   SetIndexStyle(0,DRAW_LINE,STYLE_SOLID,2,SteelBlue);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexBuffer(0,CCIBuffer1);
   SetIndexBuffer(1,CCIBuffer2);
//----
   SetIndexDrawBegin(0,CCIPeriod1);
   SetIndexDrawBegin(1,CCIPeriod1);
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| CCI_Woodies                                                         |
//+------------------------------------------------------------------+
int start()
  {
   int i,counted_bars=IndicatorCounted();
//----
   if(Bars<=CCIPeriod1) return(0);
//---- initial zero
   if(counted_bars<1)
      for(i=1;i<=CCIPeriod1;i++) CCIBuffer1[Bars-i]=0.0;
//----
   i=Bars-CCIPeriod1-1;
   if(counted_bars>=CCIPeriod1) i=Bars-counted_bars-1;
   while(i>=0)
     {
      CCIBuffer1[i]=iCCI(NULL,0,CCIPeriod1,PRICE_TYPICAL,i);
      CCIBuffer2[i]=iCCI(NULL,0,CCIPeriod2,PRICE_TYPICAL,i);
      i--;
     }
   return(0);
  }
//+------------------------------------------------------------------+

Recommend