///+------------------------------------------------------------------+
//|                                                     CCI_histo.mq4 |
 //+------------------------------------------------------------------+
#property indicator_separate_window
#property indicator_buffers 2
#property indicator_color1 LimeGreen
#property indicator_width1 2
#property indicator_color2 Violet
#property indicator_width2 2
#property indicator_maximum 20
#property indicator_minimum 0
//**************************************************************************/
extern int CCI1=14;
extern int Level1=0;
extern int CCI2=80;
extern int Level2=50;
extern int Width=3;
extern int Глубина=1400;
double rBuffer1[], rBuffer2[];
//+------------------------------------------------------------------+
int init()  {
   SetIndexBuffer(0,rBuffer1);   SetIndexStyle(0,DRAW_HISTOGRAM, EMPTY, Width);
   SetIndexBuffer(1,rBuffer2);   SetIndexStyle(1,DRAW_HISTOGRAM, EMPTY, Width);
   IndicatorDigits(MarketInfo(Symbol(),MODE_DIGITS)+1);
   IndicatorShortName("3-CCI");
   return(0);
}
//+------------------------------------------------------------------+
int start()  {
   double cci1, cci2;
   int    i,limit,counted_bars=IndicatorCounted();
   limit=Bars-counted_bars;
   if(limit>Глубина) limit=Глубина;   
   for(i=limit;i>=0;i--)  {
     rBuffer1[i]=0;  rBuffer2[i]=0;
     cci1=iCCI(NULL, 0, CCI1, PRICE_CLOSE, i);
     cci2=iCCI(NULL, 0, CCI2, PRICE_CLOSE, i);
     if(cci1>=Level1 && cci2>=Level2)   rBuffer1[i]=1;
     if(cci1<-Level1 && cci2<=-Level2)      rBuffer2[i]=1;
   }
   return(0);
  }
//+------------------