//+--------------------------------------------------+ //| Duel CCI w/Signal | //| Copyright 2009, fxVolatility.com | //| Authors: Mark Whistler/EcTrader.net | //| Mark@WallStreetRockStar.com | //|www.WallStreetRockStar.com|www.fxVolatility.com. | //+--------------------------------------------------+ #property copyright "Copyright 2009, Mark Whistler" #property link "http://www.wallstreetrockstar.com" #property indicator_separate_window #property indicator_buffers 4 #property indicator_color1 SteelBlue #property indicator_color2 Red #property indicator_color3 OrangeRed #property indicator_width3 2 #property indicator_color4 MediumSpringGreen #property indicator_width4 2 //---- input parameters extern int CCIPeriod1 = 14; extern int CCIPeriod2 = 100; extern int Num_CountBarOf220To64=10000; extern int Num_Bigger=220; extern int Num_Smaller=64; int count; //---- buffers double CCIBuffer1[]; double CCIBuffer2[]; double CCIArrow1[]; double CCIArrow2[]; //+---------------------------------------------------+ //| Begin Custom Indicator | //+---------------------------------------------------+ int deinit() { //ObjectsDeleteAll(); return(0); } int init() { string short_name; //---- indicator line SetIndexStyle(0, DRAW_LINE, STYLE_SOLID, 1, SteelBlue); SetIndexStyle(1, DRAW_LINE); SetIndexStyle(2,DRAW_ARROW); SetIndexStyle(3,DRAW_ARROW); SetIndexBuffer(0, CCIBuffer1); SetIndexBuffer(1, CCIBuffer2); SetIndexBuffer(2, CCIArrow1); SetIndexBuffer(3, CCIArrow2); SetIndexArrow(2,234); SetIndexArrow(3,233); //---- name for DataWindow and indicator subwindow label short_name = "CCIW(" + CCIPeriod1 + ", " + CCIPeriod2 + ")"; IndicatorShortName(short_name); SetIndexLabel(0, "CCIW(" + CCIPeriod1 + ")"); SetIndexLabel(1, "CCIW(" + CCIPeriod2 + ")"); SetIndexLabel(2, "CCIW(" + "CCIArrow1" + ")"); SetIndexLabel(3, "CCIW(" + "CCIArrow2" + ")"); //---- SetIndexDrawBegin(0, CCIPeriod1); SetIndexDrawBegin(1, CCIPeriod2); SetIndexDrawBegin(2, CCIArrow1); SetIndexDrawBegin(3, CCIArrow2); //---- return(0); } //+---------------------------------------------------+ //| CCI | //+---------------------------------------------------+ int start() { int i, counted_bars = IndicatorCounted(); //---- if(Bars <= CCIPeriod1) return(0); //---- initial zero if(counted_bars < 1) for(i = 1; i <= CCIPeriod1; i++) CCIBuffer1[Bars-i] = 0.0; //---- i = Bars - CCIPeriod1 - 1; if(counted_bars >= CCIPeriod1) i = Bars - counted_bars - 1; bool success1=false; bool success2=false; int j=1; while(i >= 0) { CCIBuffer1[i] = iCCI(NULL, 0, CCIPeriod1, PRICE_TYPICAL, i); CCIBuffer2[i] = iCCI(NULL, 0, CCIPeriod2, PRICE_TYPICAL, i); if (CCIBuffer2[i]<=Num_Smaller && CCIBuffer2[i+1]>=Num_Smaller) { for (j=1; j<=Num_CountBarOf220To64; j++) { if (CCIBuffer2[j+i]=Num_Bigger) { success1=true; break; } }//} if (success1==true) { CCIArrow1[i]=CCIBuffer2[i]; count++; success1=false; } else { CCIArrow1[i]=EMPTY_VALUE; } } //----------------------------- if (CCIBuffer2[i]>=(-1*Num_Smaller) && CCIBuffer2[i+1]<=(- 1*Num_Smaller)) { for (j=1; j<=Num_CountBarOf220To64; j++) { if (CCIBuffer2[j+i]>(-1*Num_Smaller)) { success2=false; break; } if (CCIBuffer2[j+i]<=(-1*Num_Bigger)) { success2=true; break; } }//} if (success2==true) { CCIArrow2[i]=CCIBuffer2[i]; success2=false; } else { CCIArrow2[i]=EMPTY_VALUE; } } success1=false; success2=false; i--; } return(0); }