Navigation:Home > Content >

cci_x2_smzCrossSig_cw.mq4

Time: 2018-11-26 | Download file:cci_x2_smzCrossSig_cw.mq4

//+------------------------------------------------------------------+
//|                                            cci_x2_smzCrossSig_cw |
//|                                        http://www.metaquotes.net |
//+------------------------------------------------------------------+
//2009fxtsd   ki

#property copyright ""
#property link      ""

#property indicator_chart_window
#property indicator_buffers 4

#property indicator_color1 Yellow
#property indicator_color2 Orange
#property indicator_color3 Lime
#property indicator_color4 Green



#property indicator_width1 2
#property indicator_width2 2
#property indicator_width3 3
#property indicator_width4 3


//---- input parameters

extern int      CCI1_period =14;
extern int      CCI1_price  =5;

extern int      CCI2_period =34;
extern int      CCI2_price  =5;

extern int      cciLevel_PosNeg = 100;


extern int  MA1_period   =5;
extern int  MA1_mode     =0;

extern int  MA2_period   =5;
extern int  MA2_mode     =0;

extern double arrowDist  =1.1;

extern string   note_Price = "0C 1O 2H 3L 4Md 5Tp 6WghC: Md(HL/2)4,Tp(HLC/3)5,Wgh(HLCC/4)6";
extern string   MA_Method_ = "SMA0 EMA1 SMMA2 LWMA3";

//---- 
double Buffer1[];
double Buffer2[];
double Buffer3[];
double Buffer4[];
double Buffer5[];
double Buffer6[];
double Buffer7[];
double Buffer8[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
   IndicatorBuffers(8); 

   //----
   SetIndexStyle(0, DRAW_ARROW); SetIndexArrow(0, 158);  SetIndexEmptyValue(0,EMPTY_VALUE);
   SetIndexStyle(1, DRAW_ARROW); SetIndexArrow(1, 158);  SetIndexEmptyValue(1,EMPTY_VALUE);
   SetIndexStyle(2, DRAW_ARROW); SetIndexArrow(2, 158);  SetIndexEmptyValue(2,EMPTY_VALUE);
   SetIndexStyle(3, DRAW_ARROW); SetIndexArrow(3, 158);  SetIndexEmptyValue(3,EMPTY_VALUE);

   SetIndexBuffer(0, Buffer1);
   SetIndexBuffer(1, Buffer2);
   SetIndexBuffer(2, Buffer3);
   SetIndexBuffer(3, Buffer4);


   SetIndexBuffer(4, Buffer5);
   SetIndexBuffer(5, Buffer6);
   SetIndexBuffer(6, Buffer7);
   SetIndexBuffer(7, Buffer8);



   string shortnme;
   shortnme = "("+CCI1_period+","+MA1_period+") ("+CCI2_period+","+MA2_period+")";
   
   IndicatorShortName("cci cross  "+shortnme);  

   SetIndexLabel(0,"cci x "+shortnme);
   SetIndexLabel(1,"cci smz x "+shortnme);
   SetIndexLabel(2,"ccix100 "+shortnme);
   SetIndexLabel(3,"cci smzx100 "+shortnme);

   //----
   return(0);
  }
//+------------------------------------------------------------------+

int deinit()
  {
    return(0);
  }
//+------------------------------------------------------------------+

int start()
  {
   int i,limit;
   int counted_bars = IndicatorCounted();
//---- 
   if(counted_bars < 0)        return(-1);
   if(counted_bars > 0)        counted_bars--;

   limit = Bars - counted_bars;


   for(i = limit; i >= 0; i--)
     {
     
      Buffer5[i]=iCCI(NULL,0,CCI1_period,CCI1_price,i);
      Buffer6[i]=iCCI(NULL,0,CCI2_period,CCI2_price,i);
     
     }


   for(i = limit; i >= 0; i--)
     {
     
      Buffer7[i]=iMAOnArray(Buffer5,0,MA1_period,0,MA1_mode, i);
      Buffer8[i]=iMAOnArray(Buffer6,0,MA2_period,0,MA2_mode, i);
     }

//
 
    for(i = limit; i >= 0; i--)
     {
   
     
      Buffer1[i] =EMPTY_VALUE; Buffer2[i] =EMPTY_VALUE; Buffer3[i] =EMPTY_VALUE; Buffer4[i] =EMPTY_VALUE; 


   if (Buffer5[i]>Buffer6[i]&&Buffer5[i+1]<=Buffer6[i+1])  Buffer1[i]= Low[i]-arrowDist*iATR(NULL,0,7,i);  
      
   if (Buffer5[i]=Buffer6[i+1])  Buffer1[i]= High[i]+ arrowDist*iATR(NULL,0,7,i);  
      
      
      
   if (Buffer7[i]>Buffer8[i]&&Buffer7[i+1]<=Buffer8[i+1])  Buffer2[i]= Low[i]-1.2*arrowDist*iATR(NULL,0,7,i);  
      
   if (Buffer7[i]=Buffer8[i+1])  Buffer2[i]= High[i]+ 1.2*arrowDist*iATR(NULL,0,7,i);  
      
      
     
      

   if (Buffer5[i]>cciLevel_PosNeg && Buffer6[i]>cciLevel_PosNeg && (Buffer5[i+1]<=cciLevel_PosNeg||Buffer6[i+1]<=cciLevel_PosNeg) )
  
                                                            Buffer3[i]=Low [i]-1.4*arrowDist*iATR(NULL,0,7,i);  

   if (Buffer5[i]<-cciLevel_PosNeg && Buffer6[i]<-cciLevel_PosNeg && (Buffer5[i+1]>=-cciLevel_PosNeg||Buffer6[i+1]>=-cciLevel_PosNeg) )

                                                            Buffer3[i]=High [i]+ 1.4*arrowDist*iATR(NULL,0,7,i);  

   

   if (Buffer7[i]>cciLevel_PosNeg && Buffer8[i]>cciLevel_PosNeg && (Buffer7[i+1]<=cciLevel_PosNeg||Buffer8[i+1]<=cciLevel_PosNeg) )
  
                                                            Buffer4[i]= Low[i] -1.7*arrowDist*iATR(NULL,0,7,i);  

   if (Buffer7[i]<-cciLevel_PosNeg && Buffer8[i]<-cciLevel_PosNeg && (Buffer7[i+1]>=-cciLevel_PosNeg||Buffer8[i+1]>=-cciLevel_PosNeg) )

                                                            Buffer4[i]= High[i]+1.7*arrowDist*iATR(NULL,0,7,i);  

   
   
      
      
      }

//----
   return(0);
  }
//+------------------------------------------------------------------+

Recommend