Hello FF!
i made a tiny revision to a code to create this CCI Cross indicator for an FF friend.
the issue is, he also wants a num_bar parameter just like in the WoodiesCCI indicator (see below)
i still lack sufficient skills to incorporate that in the indicator.
all replies are appreciated.
btw, my personal question is, does the number of bars ( num_bar ) calculated always affect the CPU resources? (that is, does smaller input on num_bar always = less CPU resource usage?) or is there no effect at all?
Thank you very much!
i made a tiny revision to a code to create this CCI Cross indicator for an FF friend.
the issue is, he also wants a num_bar parameter just like in the WoodiesCCI indicator (see below)
i still lack sufficient skills to incorporate that in the indicator.
all replies are appreciated.
btw, my personal question is, does the number of bars ( num_bar ) calculated always affect the CPU resources? (that is, does smaller input on num_bar always = less CPU resource usage?) or is there no effect at all?
Thank you very much!
Inserted Code
//+------------------------------------------------------------------+ //| CCI Cross.mq4 | //+------------------------------------------------------------------+ #property indicator_separate_window #property indicator_buffers 2 #property indicator_color1 DodgerBlue #property indicator_color2 Sienna #property indicator_width3 2 #property indicator_level1 100 #property indicator_level2 200 #property indicator_level3 -100 #property indicator_level4 -200 #property indicator_levelcolor Black //---- input parameters extern int FastCCI=10; extern int SlowCCI=20; //---- buffers double FastCCIBuffer[]; double SlowCCIBuffer[]; //---- variables int indexbegin = 0; //+------------------------------------------------------------------+ //| Custom indicator initialization function | //+------------------------------------------------------------------+ int init() { //---- indicators SetIndexStyle(0, DRAW_LINE); SetIndexBuffer(0, FastCCIBuffer); SetIndexLabel(0, "Fast CCI"); SetIndexEmptyValue(0, 0.0); SetIndexStyle(1, DRAW_LINE); SetIndexBuffer(1, SlowCCIBuffer); SetIndexLabel(1, "Slow CCI"); SetIndexEmptyValue(1, 0.0); //---- indexbegin = Bars - 20; if (indexbegin < 0) indexbegin = 0; return(0); } //+------------------------------------------------------------------+ //| Custor indicator deinitialization function | //+------------------------------------------------------------------+ int deinit() { //---- TODO: add your code here //---- return(0); } //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int i; int counted_bars = IndicatorCounted(); //---- check for possible errors if (counted_bars < 0) counted_bars = 0; //---- last counted bar will be recounted if (counted_bars > 0) counted_bars--; if (counted_bars > indexbegin) counted_bars = indexbegin; for (i = indexbegin-counted_bars; i >= 0; i--) { FastCCIBuffer[i]=iCCI(NULL,0,FastCCI,PRICE_TYPICAL,i); SlowCCIBuffer[i]=iCCI(NULL,0,SlowCCI,PRICE_TYPICAL,i); } return(0); }
Inserted Code
//---- input parameters extern int A_period=14; extern int B_period=6; extern int [b]num_bars[/b]=550; // parameters int shift=0; bool initDone=true; // было init int bar=0; int prevbars=0; int startpar=0; // было start int cs=0; int prevcs=0; string commodt="nonono"; int frame=0; int bars=0; ......... //+------------------------------------------------------------------+ //| Custom indicator iteration function | //+------------------------------------------------------------------+ int start() { int counted_bars=IndicatorCounted(); //---- TODO: add your code here cs= A_period+B_period+num_bars; //checksum used to see if parameters have been changed if ((cs==prevcs)&&(commodt==Symbol())&&(frame==(Time[4]-Time[5]))&&((Bars-prevbars)<2)) startpar=Bars-prevbars; else startpar=-1; //params haven't changed only need to calculate new bar commodt=Symbol(); frame=Time[4]-Time[5]; prevbars = Bars; prevcs = cs; if (startpar==1 | startpar==0) bar=startpar; else initDone = true; if (initDone) { FastWoodieCCI[num_bars-1]=0; SlowWoodieCCI[num_bars-1]=0; HistoWoodieCCI[num_bars-1]=0; //SetIndexValue(num_bars-1, 0); //SetIndexValue2(num_bars-1, 0); bar=num_bars-2; initDone=false; } //SetLoopCount(0); for (shift = bar;shift>=0;shift--) { ..............