i-PassLevCCI_v.1.3

Author: Gentor, KimIV, extesy
i-PassLevCCI_v.1.3
Indicators Used
Commodity channel index
0 Views
0 Downloads
0 Favorites
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;
        }
     }
  }
//+------------------------------------------------------------------+

Comments

Markdown supported. Formatting help

Markdown Formatting Guide

Element Markdown Syntax
Heading # H1
## H2
### H3
Bold **bold text**
Italic *italicized text*
Link [title](https://www.example.com)
Image ![alt text](image.jpg)
Code `code`
Code Block ```
code block
```
Quote > blockquote
Unordered List - Item 1
- Item 2
Ordered List 1. First item
2. Second item
Horizontal Rule ---