//+------------------------------------------------------------------+
//|                                                      ProjectName |
//|                                      Copyright 2012, CompanyName |
//|                                       http://www.companyname.net |
//+------------------------------------------------------------------+
/*
   G e n e r a t e d  by ex4-to-mq4 decompiler FREEWARE 4.0.509.5
   Website:  HT Tp : //ww W .MEtaqU oT eS .ne T
   E-mail :  Su P Po r t @Me t Aq U oTE s .N e T
*/

#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 Blue
#property indicator_color2 Red
#property indicator_color3 Green

double dUpCCIBuffer[];
double dDownCCIBuffer[];
double dSellBuffer[];

extern int CCI_Period=14;
extern int SoundAlertMode=1;

double Buff;
double Buff1;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int init() 
  {
   SetIndexBuffer(0,dUpCCIBuffer);
   SetIndexBuffer(1,dDownCCIBuffer);
   SetIndexBuffer(2,dSellBuffer);
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,233);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,234);
   SetIndexStyle(2,DRAW_ARROW);
   SetIndexArrow(2,SYMBOL_CHECKSIGN);
   SetIndexEmptyValue(0, 0.0);
   SetIndexEmptyValue(1, 0.0);
   SetIndexEmptyValue(2, 0.0);
   SetIndexLabel(0,"CCI Buy");
   SetIndexLabel(1,"CCI Sell");
   SetIndexLabel(2,"Exit");
   return (0);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int start() 
  {
   int nBars;
   double myCCInow;
   double myCCI2;
   string AleretText;
   int nCountedBars=IndicatorCounted();
   if(nCountedBars < 0) return (-1);
   if(nCountedBars<=3) nBars=Bars-nCountedBars-4;
   if(nCountedBars>2) 
     {
      nCountedBars--;
      nBars=Bars-nCountedBars-1;
     }

   for(int i=Bars; i>0; i--) 
     {
      dUpCCIBuffer[i]=0;
      dDownCCIBuffer[i]=0;

      myCCInow=iCCI(NULL,0,CCI_Period,PRICE_CLOSE,i);
      myCCI2=iCCI(NULL,0,CCI_Period,PRICE_CLOSE,i+1);

      if(myCCInow>=0)
         if(myCCInow>0 && myCCI2<0) dUpCCIBuffer[i]=Low[i]-2*MarketInfo(Symbol(),MODE_POINT);
      if(myCCInow<0)
         if(myCCInow<0 && myCCI2>0) dDownCCIBuffer[i]=High[i]+2*MarketInfo(Symbol(),MODE_POINT);
     }
   if(Buff!=dUpCCIBuffer[1]) 
     {
      AleretText=" "+Symbol()+" M"+Period()+": BUYSTOP is changed";
      if(SoundAlertMode>0) Alert(AleretText);
     }

   if(Buff1!=dDownCCIBuffer[1]) 
     {
      AleretText=" "+Symbol()+" M"+Period()+": SELLSTOP is changed";
      if(SoundAlertMode>0) Alert(AleretText);
     }
   
   Buff=dUpCCIBuffer[1];
   Buff1=dDownCCIBuffer[1];
   
   return (0);
  }
//+------------------------------------------------------------------+
