//+------------------------------------------------------------------+
//|                                                #KinoCCIsF4M.mq4  |
//|                      Copyright © 2008, MetaQuotes Software Corp. |
//|                                     http://kinonen.over-blog.com |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2007, MetaQuotes Software Corp."
#property link      "http://kinonen.over-blog.com"


#property indicator_separate_window
#property indicator_buffers 5
#property indicator_color1 Yellow
#property indicator_color2 Lime
#property indicator_color3 DarkGreen
#property indicator_color5 Maroon
#property indicator_color4 Red


extern int CCI1=34;
extern int CCI2=170;

//---- buffers 
double ExtMapBuffer1[];
double ExtMapBuffer2[];
double ExtMapBuffer3[];
double ExtMapBuffer4[];
double ExtMapBuffer5[];


//+------------------------------------------------------------------+
//| expert initialization function                                   |
//+------------------------------------------------------------------+
int init()
  {
 //---- indicators
   SetIndexStyle(0,DRAW_LINE, EMPTY, 3, Yellow);
   SetIndexBuffer(0,ExtMapBuffer1);
   SetIndexStyle(1,DRAW_HISTOGRAM, EMPTY, 3, Lime);
   SetIndexBuffer(1,ExtMapBuffer2);
   SetIndexStyle(2,DRAW_HISTOGRAM, EMPTY, 3, DarkGreen);
   SetIndexBuffer(2,ExtMapBuffer3);
   SetIndexStyle(3,DRAW_HISTOGRAM, EMPTY, 3, Red );
   SetIndexBuffer(3,ExtMapBuffer4);
   SetIndexStyle(4,DRAW_HISTOGRAM, EMPTY, 3, Maroon);
   SetIndexBuffer(4,ExtMapBuffer5);
   //SetIndexStyle(5,DRAW_LINE, EMPTY, 3, Red);
   // SetIndexBuffer(5,ExtMapBuffer6);
   SetIndexLabel(0,"CCI1");
   SetIndexLabel(1,"CCI 0/100");  
   SetIndexLabel(2,"CCI>100+");
   SetIndexLabel(3,"CCI<0 -100");
   SetIndexLabel(4,"CCI< -100");
      
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert deinitialization function                                 |
//+------------------------------------------------------------------+
int deinit()
  {
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| expert start function                                            |
//+------------------------------------------------------------------+
int start()
  {int limit;
   double val1,val2,val3,val5,val4;
   int counted_bars = IndicatorCounted();
   //---- check for possible errors
   if(counted_bars < 0) 
       return(-1);
   //---- last counted bar will be recounted
   if(counted_bars > 0) 
       counted_bars--;
   limit = Bars - counted_bars;
   //==========================================
   for(int i = 1000; i >= 0; i--) 
  { 
  val1=iCCI(NULL,0,CCI1,PRICE_TYPICAL,i);
  val2=iCCI(NULL,0,CCI2,PRICE_TYPICAL,i);
  
  
  ExtMapBuffer1[i]=val1;  //CCI34
  
  if (val2>=0&& val2<=100)
  ExtMapBuffer2[i]=val2;
  else
  if (val2>=100)
  ExtMapBuffer3[i]=val2;
  else
  if (val2<=0&& val2>=-100)
  ExtMapBuffer4[i]=val2;
  else
  if (val2<=-100)
  ExtMapBuffer5[i]=val2;
  }
//----
   
//----
   return(0);
  }
//+------------------------------------------------------------------+