iCCI array out of range
Hello!
I'm trying to do an CCI indicator but show the error array out of range .
Follow my code and please help me!!
You have inserted the code correctly - thanks for that. Please (for the future) do one more additional action: attach (using the button
) Your code. Why you need to do this: it's so easy to check - I click on the attached file and the browser downloads this file right away. All I have to do is click on the downloaded file and the file will open in MetaEditor.
Corrected code - you need to be more careful with indexes.
*** if(!FillArrayFromBuffer(BufferCCI,handle_iCCI,values_to_copy)) return(0); //--- main loop int limit=prev_calculated-1; if(prev_calculated==0) limit=1; for(int i=limit; i<rates_total; i++) { OpenBuffer[i]=open[i]; HighBuffer[i]=high[i]; LowBuffer[i]=low[i]; CloseBuffer[i]=close[i]; CandlesColors[i]=0.0; //--- if(BufferCCI[i-1]<0.0 && BufferCCI[i]>=0.0) { CandlesColors[i]=1.0; } if(BufferCCI[i-1]>0.0 && BufferCCI[i]<=0.0) { CandlesColors[i]=0.0; } if(BufferCCI[i]>=0.0) { CandlesColors[i]=1.0; } else { CandlesColors[i]=0.0; } } //--- memorize the number of values in the Commodity Channel Index indicator bars_calculated=calculated; //--- return the prev_calculated value for the next call return(rates_total); } ***
I added the CCI indicator to the chart:

You have inserted the code correctly - thanks for that. Please (for the future) do one more additional action: attach (using the button ) Your code. Why you need to do this: it's so easy to check - I click on the attached file and the browser downloads this file right away. All I have to do is click on the downloaded file and the file will open in MetaEditor.
Sorry about it, it's my first time to do here...
Corrected code - you need to be more careful with indexes.
Ok, I'll see where I write indexes and I'll rewrite
Thank you!
Hello!
I'm trying to do an CCI indicator but show the error array out of range.
Follow my code and please help me!!