i-PassLevCCI_v.1.3





//+------------------------------------------------------------------+
//|                                           i-PassLevCCI_v.1.2.mq4 |
//|                              Èäåÿ Gentor, ðåàëèçàöèÿ â ÌÒ4 KimIV |
//|                                              http://www.kimiv.ru |
//|   23.08.2005 v.1.0                                               |
//| Ïîñëåäîâàòåëüíûé ïðîõîä ÑÑÈ ÷åðåç óðîâíè -100, 0 è 100           |
//|   24.08.2005 v.1.1                                               |
//| Èñïðàâëÿþ îøèáêó â àëãîðèòìå.                                    |
//|   25.08.2005 v.1.2                                               |
//| Èñïðàâèë îøèáêó, íàéäåííóþ extesy. Respect                       |
//|   26.08.2005 v.1.3                                               |
//| Îïòèìèçèðîâàí àëãîðèòì. Èñïðàâëåíû áàãè.                         |
//+------------------------------------------------------------------+
#property copyright "Gentor, KimIV, extesy"
#property link      "http://www.kimiv.ru"
//----
#property indicator_chart_window
#property indicator_buffers 3
#property indicator_color1 PaleTurquoise
#property indicator_color2 LightSalmon
#property indicator_color3 Red
//------- Âíåøíèå ïàðàìåòðû ------------------------------------------
extern int CCI_Period  =14;   // Ïåðèîä CCI
extern int BarsForCheck=9;    // Êîëè÷åñòâî áàðîâ äëÿ ïðîâåðêè
extern int MaxLevel    =100;  // Ìàêñèìàëüíîå çíà÷åíèå óðîâíÿ
extern int MinLevel    =-100; // Ìèíèìàëüíîå çíà÷åíèå óðîâíÿ
extern int NumberOfBars=0;    // Êîëè÷åñòâî áàðîâ îáñ÷¸òà (0-âñå)
//------- Áóôåðû èíäèêàòîðà ------------------------------------------
double SigBuy[];
double SigSell[];
double SigExit[];
//------- Ãëîáàëüíûå ïåðåìåííûå --------------------------------------
bool firstTime=True;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
  void init() 
  {
   SetIndexBuffer(0, SigBuy);
   SetIndexStyle (0, DRAW_ARROW);
   SetIndexArrow (0, 233);
   SetIndexBuffer(1, SigSell);
   SetIndexStyle (1, DRAW_ARROW);
   SetIndexArrow (1, 234);
   SetIndexBuffer(2, SigExit);
   SetIndexStyle (2, DRAW_ARROW);
   SetIndexArrow (2, 251);
   Comment("");
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
  void start() 
  {
   bool     fsb=False, fss=False, sig;
   double   cci0, cci1, cci2, cci3;
   int      loopbegin, shift, sh, i;
//----   
     if (firstTime) 
     {
      if (NumberOfBars==0) loopbegin=Bars - 1 - CCI_Period;
      else loopbegin=NumberOfBars - 1;
     }
   if (BarsForCheck<2) BarsForCheck=2;
     for(shift=loopbegin; shift>=0; shift--) 
     {
      SigBuy[shift]=EMPTY_VALUE;
      SigSell[shift]=EMPTY_VALUE;
      SigExit[shift]=EMPTY_VALUE;
      cci0=iCCI(NULL, 0, CCI_Period, PRICE_TYPICAL, shift+1);
      sig=False;
      // Ñèãíàë íà ïîêóïêó
        if (cci0>MaxLevel) 
        {
           for(sh=2; sh<=BarsForCheck; sh++) 
           {
            if (fsb) break;
            cci1=iCCI(NULL, 0, CCI_Period, PRICE_TYPICAL, shift+sh-1);
            cci2=iCCI(NULL, 0, CCI_Period, PRICE_TYPICAL, shift+sh);
              if (cci1>cci2) 
              {
                 if (cci2<MinLevel) 
                 {
                  SigBuy[shift]=Low[shift] - 10 * Point;
                  fsb=True; fss=False; sig=True; break;
                 }
              } 
              else break;
           }
        }
      // Ñèãíàë íà ïðîäàæó
        if (cci0<MinLevel) 
        {
           for(sh=2; sh<=BarsForCheck; sh++) 
           {
            if (fss) break;
            cci1=iCCI(NULL, 0, CCI_Period, PRICE_TYPICAL, shift+sh-1);
            cci2=iCCI(NULL, 0, CCI_Period, PRICE_TYPICAL, shift+sh);
              if (cci1<cci2) 
              {
                 if (cci2>MaxLevel) 
                 {
                  SigSell[shift]=High[shift] + 10 * Point;
                  fss=True; fsb=False; sig=True; break;
                 }
              } 
              else break;
           }
        }
      // Ñèãíàëû íà âûõîä
      cci3=iCCI(NULL, 0, CCI_Period, PRICE_TYPICAL, shift+2);
        if (cci0*cci3<0 && (fsb || fss) && !sig) 
        {
         SigExit[shift]=Close[shift];
         fsb=False;
         fss=False;
        }
     }
  }
//+------------------------------------------------------------------+





Sample





Analysis



Market Information Used:

Series array that contains the lowest prices of each bar
Series array that contains the highest prices of each bar
Series array that contains close prices for each bar


Indicator Curves created:



Indicators Used:

Commodity channel index


Custom Indicators Used:

Order Management characteristics:

Other Features: