Navigation:Home > Content >

kino_2CCI_Cross_Alert_v2.mq4

Time: 2017-08-19 | Download file:kino_2CCI_Cross_Alert_v2.mq4

//+------------------------------------------------------------------+
//|                                   kino_    2CCI_Cross_Alert.mq4  |
//|                   Copyright © 2008, KINONEN                      |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2008 KINONEN."
#property indicator_chart_window

extern int CCI1   =  79;
extern int CCI2   =   24;
extern int value1 =    0;
extern int value2 = 250;
extern bool alert = true ;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init()
  {
//---- indicators
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custor indicator deinitialization function                       |
//+------------------------------------------------------------------+
int deinit()
  {
//---- 
   
//----
   return(0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start()
  {
   int    counted_bars=IndicatorCounted();
   double CCI1_0, CCI1_1, CCI2_0;
   
   CCI1_0 = iCCI(NULL, 0, CCI1, PRICE_TYPICAL, 0);
   CCI1_1 = iCCI(NULL, 0, CCI1, PRICE_TYPICAL, 1);
   CCI2_0 = iCCI(NULL, 0, CCI2, PRICE_TYPICAL, 0);
   
//---- 
   //Print(CCI1_0, "...", CCI1_1, "...", CCI2_0);

   if(CCI2_0 < value1 && alert) 
     {
      if((CCI1_0 < value1) && (CCI1_1 >= value1))
      {
         Alert(Symbol(), " M", Period(), " CCI1&CCI2 have both crossed below " + value1);
      }
     }
   else if(CCI2_0 > value1&& alert) 
     {
      if((CCI1_0 > value1) && (CCI1_1 <= value1)) 
      {
         Alert(Symbol(), " M", Period(), " CCI1&CCI2 have both crossed above "+ value1);
      }
     }
   if(CCI2_0 < value2 && alert)
     {
      if((CCI1_0 < value2) && (CCI1_1 >= value2))
      {
         Alert(Symbol(), " M",Period(), " CCI1&CCI2 have both crossed below " + value2);
      }
     }
   else if(CCI2_0 > value2 && alert) 
     {
      if((CCI1_0 > value2) && (CCI1_1 <= value2)) 
      {
         Alert(Symbol(), " M",Period(), " CCI1&CCI2 have both both crossed above "+ value2);
      }
     }  
   Comment("        ");  
   Comment("CCI1: ", CCI1_0, " CCI2: ", CCI2_0);
   
//----
   return(0);
  }
//+------------------------------------------------------------------+

Recommend