Author: johnfantom & KimIV
Indicators Used
Commodity channel index
Miscellaneous
Implements a curve of type %1
1 Views
0 Downloads
0 Favorites
i-3CCI-h
//+------------------------------------------------------------------+
//|                                                     i-3CCI-h.mq4 |
//|                                               johnfantom & KimIV |
//|                                              http://www.kimiv.ru |
//+------------------------------------------------------------------+
#property copyright "johnfantom & KimIV"
#property link      "http://www.kimiv.ru"

#property indicator_separate_window
#property indicator_buffers 1
#property indicator_color1 DodgerBlue
#property indicator_maximum 1.4
#property indicator_level1  0
#property indicator_minimum -1.2

//------- Âíåøíèå ïàðàìåòðû èíäèêàòîðà -------------------------------
extern int CCI_Period_0 = 14;     // Ïåðèîä CCI äëÿ òåêóùåãî ÒÔ
extern int Level_0      = 100;    // Óðîâåíü CCI äëÿ òåêóùåãî ÒÔ
extern int TF_1         = 60;     // Êîëè÷åñòâî ìèíóò ïåðâîãî ÒÔ
extern int CCI_Period_1 = 14;     // Ïåðèîä CCI äëÿ ïåðâîãî ÒÔ
extern int Level_1      = 100;    // Óðîâåíü CCI äëÿ ïåðâîãî ÒÔ
extern int TF_2         = 240;    // Êîëè÷åñòâî ìèíóò âòîðîãî ÒÔ
extern int CCI_Period_2 = 14;     // Ïåðèîä CCI äëÿ âòîðîãî ÒÔ
extern int Level_2      = 100;    // Óðîâåíü CCI äëÿ âòîðîãî ÒÔ
extern int NumberOfBars = 10000;  // Êîëè÷åñòâî áàðîâ îáñ÷¸òà (0-âñå)

//------- Áóôåðû èíäèêàòîðà ------------------------------------------
double buf0[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
void init() 
  {
   IndicatorDigits(1);

   SetIndexBuffer(0,buf0);
   SetIndexLabel(0,"i-3CCI-h");
   SetIndexStyle(0,DRAW_HISTOGRAM,STYLE_SOLID,2);
   SetIndexEmptyValue(0,0);
  }
//+------------------------------------------------------------------+
//| Custom indicator deinitialization function                       |
//+------------------------------------------------------------------+
void deinit() 
  {
   Comment("");
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
void start() 
  {
   double cci0,cci1,cci2;
   int    nb1,nb2;
   int    LoopBegin,sh;

   if(NumberOfBars==0) LoopBegin=Bars-1;
   else LoopBegin=NumberOfBars-1;
   LoopBegin=MathMin(Bars-1,LoopBegin);

   for(sh=LoopBegin; sh>=0; sh--) 
     {
      nb1=iBarShift(NULL, TF_1, Time[sh], False);
      nb2=iBarShift(NULL, TF_2, Time[sh], False);

      cci0=iCCI(NULL, 0   , CCI_Period_0, PRICE_CLOSE, sh);
      cci1=iCCI(NULL, TF_1, CCI_Period_1, PRICE_CLOSE, nb1);
      cci2=iCCI(NULL, TF_2, CCI_Period_2, PRICE_CLOSE, nb2);

      if(cci0>Level_0 && cci1>Level_1 && cci2>Level_2) buf0[sh]=1;
      if(cci0<-Level_0 && cci1<-Level_1 && cci2<-Level_2) buf0[sh]=-1;
     }
  }
//+------------------------------------------------------------------+

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 ---