#property copyright "Levix95"
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 LightSeaGreen
#property indicator_color2 Orange

extern int MAPeriod = 8 ;
extern int MAType = 0 ;           // 0: SMA, 1: EMA, 2: SMMA, 3: LWMA
extern int CCIPeriod = 25 ;

//---- buffers
double CCIBuffer[];
double MABuffer[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {

    SetIndexStyle(0, DRAW_LINE);
    SetIndexBuffer(0, CCIBuffer);

    SetIndexStyle(1, DRAW_LINE,STYLE_DOT,1);
    SetIndexBuffer(1, MABuffer);
    
    IndicatorShortName("CCI");
    SetIndexLabel(0, " CCI ");
    SetIndexLabel(1, " CCI-MA ");    
//---
    return(0);
  }

//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
  for(int i = 0 ; i < Bars ; i++ ){ 
      CCIBuffer[i]= iCCI(NULL, 0, CCIPeriod, PRICE_CLOSE, i);
  }
  for(i = 0 ; i < Bars ; i++ ){ 
      MABuffer[i]= iMAOnArray(CCIBuffer, 0 , MAPeriod , 0, MAType , i) ;
  }
  
  return(0); 
 }
