//+------------------------------------------------------------------+
//|                                CCI Buy-Sell Signal Indicator.mq4 |
//|                                             ForexIndicators.info |
//|                                      http://forexindicators.info |
//+------------------------------------------------------------------+
#property indicator_separate_window
#property indicator_minimum 1
#property indicator_maximum 10
#property indicator_buffers 3
#property indicator_color1 Red
#property indicator_color2 Blue
#property indicator_color3 Gray

input ENUM_TIMEFRAMES      TimeFrame         = PERIOD_CURRENT;

double maudo[];
double mauxanh[];
double mautrang[];
double trend[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
IndicatorBuffers(4);
SetIndexStyle(0,DRAW_HISTOGRAM,EMPTY,8);
SetIndexBuffer(0,maudo);

SetIndexStyle(1,DRAW_HISTOGRAM,EMPTY,8);
SetIndexBuffer(1,mauxanh);

SetIndexStyle(2,DRAW_HISTOGRAM,EMPTY,8);
SetIndexBuffer(2,mautrang);
SetIndexBuffer(3,trend);

IndicatorShortName("CCI Buy-Sell Signal");
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
{
   int counted_bars=IndicatorCounted();
      if(counted_bars<0) return(-1);
      if(counted_bars>0) counted_bars--;
           int limit=MathMin(Bars-counted_bars,Bars-1);
           int pos,y;
      datetime TimeArray[]; 
      ArrayCopySeries(TimeArray,MODE_TIME,Symbol(),TimeFrame);
      //
      //
      //
      //
      //    
      for(pos=0,y=0;pos<limit;pos++)
       {
      if (Time[pos]<TimeArray[y]) y++;
   
        double CCI_HIGH_1 = iCCI(NULL,0,12,PRICE_TYPICAL,y);
        double CCI_HIGH_2 = iCCI(NULL,0,12,PRICE_TYPICAL,y+1);
        maudo[pos]    = EMPTY_VALUE;
        mauxanh[pos]  = EMPTY_VALUE;
        mautrang[pos] = EMPTY_VALUE;
        trend[pos] = 0;
        if (CCI_HIGH_1 > CCI_HIGH_2)  trend[pos] = 1;
        if (CCI_HIGH_1 < CCI_HIGH_2)  trend[pos] =-1; 
        if (CCI_HIGH_1 == CCI_HIGH_2) trend[pos] = 0;  
        if (trend[pos] ==-1) maudo[pos]   = 10; 
        if (trend[pos] == 1) mauxanh[pos] = 10; 
        if (trend[pos] == 0) mautrang[pos]= 10; 
        
        
      }
   return(0);
  }
//+------------------------------------------------------------------+//+------------------------------------------------------------------+