//+------------------------------------------------------------------+
//|      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 ?
//http://www.forexfactory.com/showthread.php?t=114258 fxprime 5min

#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 7
#property  indicator_color1  Lime         //RSI >55 cci>0 2>100  
#property  indicator_color2  DarkGreen    //RSI >55 cci>0 1>100
#property  indicator_color3  Red          //RSI <45 
#property  indicator_color4  Maroon       //RSI <45 
#property  indicator_color5  Yellow       //other

#property  indicator_color6  Aqua          //entry fxprime long
#property  indicator_color7  Magenta       //entry fxprime short


#property indicator_width1 4
#property indicator_width2 4
#property indicator_width3 4
#property indicator_width4 4
#property indicator_width5 4
#property indicator_width6 3
#property indicator_width7 3



//---- indicator parameters      
extern int CCI1=34;
extern int CCI2=170;
extern int RSI=8;
extern int valeur1=55;
extern int valeur2=45;
extern bool FxPrimeEntry = true;
//Long: When CCI 170 is above 0 ALREADY And CCI 34 crosses up 0 And rsi above 55.//

//extern bool SoundON=true;

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

double   ExtBuffer6fp[];
double   ExtBuffer7fp[];


//+------------------------------------------------------------------+
//| 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);


   SetIndexStyle(5, DRAW_ARROW); SetIndexArrow(5, 159);  SetIndexEmptyValue(5,EMPTY_VALUE);
   SetIndexStyle(6, DRAW_ARROW); SetIndexArrow(6, 159);  SetIndexEmptyValue(6,EMPTY_VALUE);

   SetIndexBuffer(5,ExtBuffer6fp);
   SetIndexBuffer(6,ExtBuffer7fp);


   
   string shortname = " CCI "+CCI1+", CCI "+CCI2+", RSI "+RSI+", ";
//---- names
   IndicatorShortName(shortname+" kino FxPrime ");
   SetIndexLabel     (0,"RSI>55 2CCIs>0 & 2>+100");
   SetIndexLabel     (1,"RSI>55 2CCIs>0 & 1>+100");
   SetIndexLabel     (2,"RSI<45 2CCIs<0 & 2<-100");
   SetIndexLabel     (3,"RSI<45 2CCIs<0 & 1<-100");
   SetIndexLabel     (4,"bad zona");
   
   SetIndexLabel     (5,"fxprime entry long");
   SetIndexLabel     (6,"fxprime entry short");
   
   
//---- 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;
     
     ExtBuffer6fp[i]=EMPTY_VALUE;     ExtBuffer7fp[i]=EMPTY_VALUE;


      //Long: When CCI 170 is above 0 ALREADY And CCI 34 crosses up 0 And rsi 8 above 55.//

    
      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  )      
            { 
    
             // 2 cci > +100
            if  ( iCCI(NULL,0,CCI1,PRICE_TYPICAL,i)>100 && 
                  iCCI(NULL,0,CCI2,PRICE_TYPICAL,i)>100 )  
                  
                  ExtBuffer1[i]=1;
    
            else
            if  ( iCCI(NULL,0,CCI1,PRICE_TYPICAL,i)<100    || 
                  iCCI(NULL,0,CCI2,PRICE_TYPICAL,i)<100 )  
                  
                  ExtBuffer2[i]=1;
                  
                  
              
            // cci21 > 0 cci1>0
            if  ( FxPrimeEntry                            &&
                  iCCI(NULL,0,CCI1,PRICE_TYPICAL,i+1)<0   && 
                  iCCI(NULL,0,CCI2,PRICE_TYPICAL,i+1)>0 )  
                  
                  ExtBuffer6fp[i]=0.3;
                  
            }
               //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 )     
            {

               if (  iCCI(NULL,0,CCI1,PRICE_TYPICAL,i)<-100 && 
                     iCCI(NULL,0,CCI2,PRICE_TYPICAL,i)<-100 )  

                     ExtBuffer3[i]=1;


               else   
               if (  iCCI(NULL,0,CCI1,PRICE_TYPICAL,i)>-100 || 
                     iCCI(NULL,0,CCI2,PRICE_TYPICAL,i)>-100 )  

                     ExtBuffer4[i]=1;
                 

                
               if (  FxPrimeEntry                          &&
                     iCCI(NULL,0,CCI1,PRICE_TYPICAL,i+1)>0 && 
                     iCCI(NULL,0,CCI2,PRICE_TYPICAL,i+1)<0 )  
                  
                      ExtBuffer7fp[i]=0.3;
                  

              }


      else            ExtBuffer5[i]=1;
       
        
         
      } 
        
   return(0);
  }
  
//+------------------------------------------------------------------+