MACD_CCI
Indicators Used
Commodity channel indexMoving average indicator
Miscellaneous
Implements a curve of type %1
0 Views
0 Downloads
0 Favorites
MACD_CCI
//+------------------------------------------------------------------+
//|                                                     MACD_CCI.mq4 |
//|                                   Copyright © 2009, challenger78 |
//+------------------------------------------------------------------+
#property  copyright "challenger78"

#property  indicator_separate_window
#property  indicator_buffers 3
#property  indicator_color1  Blue
#property  indicator_color2  Red
#property  indicator_color3  Yellow

#property  indicator_minimum 0
#property  indicator_maximum 2

extern int FastLen = 144;
extern int SlowLen = 233;
extern int CCI = 50;

double buffer1[], buffer2[], buffer3[];

int init()
{
   SetIndexStyle(0,DRAW_ARROW);    SetIndexArrow(0,110);    SetIndexBuffer(0,buffer1);    SetIndexEmptyValue(0,EMPTY_VALUE); 
   SetIndexStyle(1,DRAW_ARROW);    SetIndexArrow(1,110);    SetIndexBuffer(1,buffer2);    SetIndexEmptyValue(1,EMPTY_VALUE);
   SetIndexStyle(2,DRAW_ARROW);    SetIndexArrow(2,110);    SetIndexBuffer(2,buffer3);    SetIndexEmptyValue(2,EMPTY_VALUE); 
   
   return(0);
}

int start()
{
   int limit;
   int counted_bars = IndicatorCounted();
   if(counted_bars < 0) return(-1);
   if(counted_bars > 0) counted_bars--;
   limit = Bars - counted_bars;
   
   for(int i = 0; i < limit; i++)
   {
      double cci =   iCCI(NULL, 0, CCI, PRICE_TYPICAL, i);
      double ma_0 = iMA(NULL, 0, FastLen, 0, MODE_EMA, PRICE_CLOSE, i) - 
                     iMA(NULL, 0, SlowLen, 0, MODE_EMA, PRICE_CLOSE, i);
      double ma_1 = iMA(NULL, 0, FastLen, 0, MODE_EMA, PRICE_CLOSE, i + 1) - 
                     iMA(NULL, 0, SlowLen, 0, MODE_EMA, PRICE_CLOSE, i + 1);
                         
      buffer1[i]=EMPTY_VALUE;    buffer2[i]=EMPTY_VALUE;      buffer3[i]=EMPTY_VALUE;    
      
      if (cci > 0 && ma_0 > ma_1) buffer1[i] = 1;  
      else if (cci < 0 && ma_0 < ma_1) buffer2[i] = 1;
      else buffer3[i] = 1;
   }
   return(0);
}

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