//+------------------------------------------------------------------+
//|      kinonen's indic  to see if 2 CCI are above/under zeroLine   |
//|                      Copyright © 2008, Pharmacien@dejante.com    |
//|                                       http://www.metaquotes.net/ |
//+------------------------------------------------------------------+
 // you are asking if CCI is above/under 45/55 ?

#property  copyright "Copyright © 2008, MetaQuotes Software Corp."
#property  link      "http://www.metaquotes.net/"
//---- indicator settings
#property indicator_separate_window
#property indicator_minimum 0
#property indicator_maximum 1

#property  indicator_buffers 5
#property  indicator_color1  DarkGreen    //RSI >55 cci>0 <100 
#property  indicator_color2  Lime         //RSI >55 cci>0 && >+100 
#property  indicator_color3  Maroon       //RSI <45 cci<0
#property  indicator_color4  Red          //RSI <45 cci<0 && <-100
#property  indicator_color5  Yellow       //other

#property indicator_width1 4
#property indicator_width2 4
#property indicator_width3 4
#property indicator_width4 4
#property indicator_width5 4

//---- indicator parameters      
extern int CCI1=34;
extern int CCI2=170;
extern int RSI=8;
extern int valeur1=55;
extern int valeur2=45;


//extern bool SoundON=true;

//---- indicator buffers
double   ExtBuffer1[];
double   ExtBuffer2[];
double   ExtBuffer3[];
double   ExtBuffer4[];
double   ExtBuffer5[];

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- drawing settings
   SetIndexStyle (0,DRAW_HISTOGRAM);
   SetIndexBuffer(0,ExtBuffer1);
   SetIndexStyle (1,DRAW_HISTOGRAM);
   SetIndexBuffer(1,ExtBuffer2);
   SetIndexStyle (2,DRAW_HISTOGRAM);
   SetIndexBuffer(2,ExtBuffer3);
   SetIndexStyle (3,DRAW_HISTOGRAM);
   SetIndexBuffer(3,ExtBuffer4);
   SetIndexStyle (4,DRAW_HISTOGRAM);
   SetIndexBuffer(4,ExtBuffer5);
   
   string shortname = " CCI "+CCI1+", CCI "+CCI2+", RSI "+RSI+", ";
//---- names
   IndicatorShortName("kino - "+shortname);
   SetIndexLabel     (0,"RSI>55 CCIs>0 & <+100");
   SetIndexLabel     (1,"RSI>55 CCIs>0 & >+100");
   SetIndexLabel     (2,"RSI<45 CCIs<0 & >-100");
   SetIndexLabel     (3,"RSI<45 CCIs<0 & <-100");
   SetIndexLabel     (4,"bad zone");
   
   
//---- initialization done
   return(0);
  }
//+------------------------------------------------------------------+
//| Moving Averages                                                  |
//+------------------------------------------------------------------+
int start()
  {
   int limit;
// int N =0; // counter of alerts 
   int counted_bars=IndicatorCounted();
//---- last counted bar will be recounted
   if(counted_bars>0) counted_bars--;
   limit=Bars-counted_bars;
//---- 
   for(int i=0; i<limit; i++)
   {
     
     ExtBuffer1[i]=0.0;     ExtBuffer2[i]=0.0;     ExtBuffer3[i]=0.0;     
     ExtBuffer4[i]=0.0;     ExtBuffer5[i]=0.0;



      //RSI > 55 & the Two CCI are >0 and <100
    
      if(iRSI(NULL,0,RSI,PRICE_CLOSE,i) >=valeur1 && 
        iCCI(NULL,0,CCI1,PRICE_TYPICAL,i)>0       && 
        iCCI(NULL,0,CCI2,PRICE_TYPICAL,i)>0       && 
        iCCI(NULL,0,CCI1,PRICE_TYPICAL,i)<=100    || 
        iCCI(NULL,0,CCI2,PRICE_TYPICAL,i)<=100 )  
        {
        ExtBuffer1[i]=1;
        }
       
       else // 2 cci > +100
        if (iRSI(NULL,0,RSI,PRICE_CLOSE,i)>=valeur1 && 
        iCCI(NULL,0,CCI2,PRICE_TYPICAL,i)>100 && 
        iCCI(NULL,0,CCI1,PRICE_TYPICAL,i)>100)  
        {
        ExtBuffer2[i]=1;
        }
     //RSI < 45 & the Two CCI are <0  but >-100
      else
      if ((iRSI(NULL,0,RSI,PRICE_CLOSE,i)<=valeur2)  && 
           (iCCI(NULL,0,CCI1,PRICE_TYPICAL,i)<=0)    && 
           (iCCI(NULL,0,CCI2,PRICE_TYPICAL,i)<=0)    && 
           (iCCI(NULL,0,CCI1,PRICE_TYPICAL,i)>=-100  || 
            iCCI(NULL,0,CCI2,PRICE_TYPICAL,i)>=-100))  
        {
           ExtBuffer3[i]=1;
        }
       else  
        // 2 cci ><-100
       if ((iRSI(NULL,0,RSI,PRICE_CLOSE,i)<=valeur2) && 
           (iCCI(NULL,0,CCI2,PRICE_TYPICAL,i)<-100)  && 
           (iCCI(NULL,0,CCI1,PRICE_TYPICAL,i)<-100))  
        {
           ExtBuffer4[i]=1;
        }
      else   // 
        {
          ExtBuffer5[i]=1;
        }
        
         
    }   
   return(0);
  }
  
//+------------------------------------------------------------------+