//+------------------------------------------------------------------+
//|                                                       CCI MA.mq4 |
//|                                                      Coders Guru |
//|                                       http://www.metatrader.info |
//+------------------------------------------------------------------+

#property copyright "Coders Guru"
#property link      "http://www.metatrader.info"


#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 Red
#property indicator_color2 DodgerBlue
#property indicator_level1 100
#property indicator_level2 0
#property indicator_level3 -100

extern int CCIPeriod = 14;
extern int MAPeriod = 3;

double ExtMapBuffer1[];
double ExtMapBuffer2[];

int init()
  {
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS));
   SetIndexStyle(0,DRAW_LINE);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_LINE,STYLE_SOLID,2);
   SetIndexBuffer(1,ExtMapBuffer2);
  
   return(0);
  }

int deinit()
  {
   return(0);
  }
  
int start()
  {
   int bar, limit;
   
   int counted_bars=IndicatorCounted();
   if(counted_bars<0) return(-1);
   if(counted_bars>0) counted_bars--;
   limit=Bars-IndicatorCounted();
    
   
   for(bar=0; bar<limit; bar++)
      ExtMapBuffer1[bar] = iCCI(NULL,0,CCIPeriod,PRICE_TYPICAL,bar);
  
   for(bar=0; bar<limit; bar++)
         ExtMapBuffer2[bar]=iMAOnArray(ExtMapBuffer1,Bars,MAPeriod,0,MODE_EMA,bar);
   
   return(0);
  }