//+------------------------------------------------------------------+ //| DoubleCCI.mq4 | //| Copyright © 2005, Jason Robinson (jnrtrading). | //| http://www.jnrtrading.co.uk | //+------------------------------------------------------------------+ #property copyright "Copyright © 2005, Jason Robinson (jnrtrading)." #property link "http://www.jnrtrading.co.uk" #property indicator_separate_window #property indicator_buffers 4 #property indicator_color1 Lime #property indicator_color2 Red #property indicator_color3 Blue #property indicator_color4 Black #property indicator_level1 50 #property indicator_level2 100 #property indicator_level3 150 #property indicator_level4 200 #property indicator_level5 -200 #property indicator_level6 -150 #property indicator_level7 -100 #property indicator_level8 -50 //---- input parameters extern int TrendCCI_Period = 50; extern int EntryCCI_Period = 14; extern bool Zero_Cross_Alert; extern bool Automatic_Timeframe_Setting; extern int M1_TrendCCI_Period = 50; extern int M1_EntryCCI_Period = 14; extern int M5_TrendCCI_Period = 50; extern int M5_EntryCCI_Period = 14; extern int M15_TrendCCI_Period = 14; extern int M15_EntryCCI_Period = 6; extern int M30_TrendCCI_Period = 14; extern int M30_EntryCCI_Period = 6; extern int H1_TrendCCI_Period = 14; extern int H1_EntryCCI_Period = 6; extern int H4_TrendCCI_Period = 14; extern int H4_EntryCCI_Period = 6; extern int D1_TrendCCI_Period = 14; extern int D1_EntryCCI_Period = 6; extern int W1_TrendCCI_Period = 14; extern int W1_EntryCCI_Period = 6; extern int MN_TrendCCI_Period = 14; extern int MN_EntryCCI_Period = 6; double TrendCCIBuffer[]; double CCIHistogramUpBuffer[]; double CCIHistogramDownBuffer[]; double EntryCCIBuffer[]; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(2, DRAW_LINE, STYLE_SOLID, 2); SetIndexBuffer(2, TrendCCIBuffer); SetIndexLabel(2, "TrendCCI"); SetIndexStyle(0, DRAW_HISTOGRAM, 0, 3); SetIndexBuffer(0, CCIHistogramUpBuffer); SetIndexStyle(1, DRAW_HISTOGRAM, 0, 3); SetIndexBuffer(1, CCIHistogramDownBuffer); SetIndexStyle(3, DRAW_LINE, STYLE_SOLID, 2); SetIndexBuffer(3, EntryCCIBuffer); SetIndexLabel(3, "EntryCCI"); //---- return(0); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int limit, i, trendCCI, entryCCI; static datetime prevtime = 0; int counted_bars = IndicatorCounted(); //---- check for possible errors if(counted_bars < 0) return(-1); //---- last counted bar will be recounted if(counted_bars > 0) counted_bars--; limit=Bars-counted_bars; if (Automatic_Timeframe_Setting == true) { switch(Period()) { case 1: trendCCI = M1_TrendCCI_Period; entryCCI = M1_EntryCCI_Period; break; case 5: trendCCI = M5_TrendCCI_Period; entryCCI = M5_EntryCCI_Period; break; case 15: trendCCI = M15_TrendCCI_Period; entryCCI = M15_EntryCCI_Period; break; case 30: trendCCI = M30_TrendCCI_Period; entryCCI = M30_EntryCCI_Period; break; case 60: trendCCI = H1_TrendCCI_Period; entryCCI = H1_EntryCCI_Period; break; case 240: trendCCI = H4_TrendCCI_Period; entryCCI = H4_EntryCCI_Period; break; case 1440: trendCCI = D1_TrendCCI_Period; entryCCI = D1_EntryCCI_Period; break; case 10080: trendCCI = W1_TrendCCI_Period; entryCCI = W1_EntryCCI_Period; break; case 43200: trendCCI = MN_TrendCCI_Period; entryCCI = MN_EntryCCI_Period; break; } } else { trendCCI = TrendCCI_Period; entryCCI = EntryCCI_Period; } IndicatorShortName("(TrendCCI: " + trendCCI + ", EntryCCI: " + entryCCI + ") "); for(i = 0; i <= limit; i++) { TrendCCIBuffer[i] = iCCI(NULL, 0, trendCCI, PRICE_TYPICAL, i); if (TrendCCIBuffer[i] >= 0 ) CCIHistogramUpBuffer[i] = TrendCCIBuffer[i]; else CCIHistogramUpBuffer[i] = 0; if (TrendCCIBuffer[i] < 0 ) CCIHistogramDownBuffer[i] = TrendCCIBuffer[i]; else CCIHistogramDownBuffer[i]=0; EntryCCIBuffer[i] = iCCI(NULL, 0, entryCCI, PRICE_TYPICAL, i); } if (Zero_Cross_Alert == true) { if (prevtime == Time[0]) { return(0); } else { if(EntryCCIBuffer[0] < 0) { if((TrendCCIBuffer[0] < 0) && (TrendCCIBuffer[1] >= 0)) { Alert(Symbol(), " M", Period(), " Trend & Entry CCI Have both crossed below zero"); } } else if(EntryCCIBuffer[0] > 0) { if((TrendCCIBuffer[0] > 0) && (TrendCCIBuffer[1] <= 0)) { Alert(Symbol(), " M", Period(), " Trend & Entry CCI Have both crossed above zero"); } } prevtime = Time[0]; } } ObjectCreate("ZeroLine", OBJ_HLINE, WindowFind("(TrendCCI: \" + trendCCI + \", EntryCCI: \" + entryCCI + \") "), 0, 0); //---- //---- return(0); } //+------------------------------------------------------------------+
Sample
image not available
Analysis
Market Information Used:
Series array that contains open time of each bar
Indicator Curves created:
Implements a curve of type DRAW_LINE
Implements a curve of type DRAW_HISTOGRAM
Indicators Used:
Commodity channel index
Custom Indicators Used:
Order Management characteristics:
Other Features:
It issuies visual alerts to the screen