Code snippets - page 4

 

A very simple function to calculate CCI : _cci.mq4

The advantage is that you can calculate cci of any value using this function (without a need to allocate one more buffer, as iCCIOnArray requires) :

double workCci[][1];

double iCci(double price, int period, int r, int instanceNo=0)

{

if (ArrayRange(workCci,0)!= Bars) ArrayResize(workCci,Bars); r=Bars-r-1;

//

//

//

//

//

workCci[r] = price;

double tcci = 0;

double avg = 0; for(int k=0; k=0; k++) avg += workCci[r-k]; avg /= period;

double dev = 0; for( k=0; k=0; k++) dev += MathAbs(workCci[r-k]-avg); dev /= period;

if (dev!=0)

tcci = (price-avg)/(0.015*dev);

return(tcci);

}
Files:
_cci.mq4  2 kb
 

Examples (for those that want experiment with CCI of "something") : cci of average and cci of stochastic

Files:
 
mladen:
Examples (for those that want experiment with CCI of "something") : cci of average and cci of stochastic

Were those posted somewhere?

 
sebastianK:
Were those posted somewhere?

CCI using average for instead of raw price was posted here (the upper one on that example) : https://www.mql5.com/en/forum/175321/page3

 
mladen:
CCI using average for instead of raw price was posted here (the upper one on that example) : https://www.mql5.com/en/forum/175321/page3

Thanks

 
mladen:
CCI using average for instead of raw price was posted here (the upper one on that example) : https://www.mql5.com/en/forum/175321/page3

Could not find the version using stochastic. Can you post the link to it, please?

 
sebastianK:
Could not find the version using stochastic. Can you post the link to it, please?

That version was not posted

Here it is : cci_of_stochastic_2.mq4

 
mladen:
That version was not posted Here it is : cci_of_stochastic_2.mq4

Thank you

 
mladen:
That version was not posted Here it is : cci_of_stochastic_2.mq4

PS: did you try CCI on some more indicators?

 
sebastianK:
PS: did you try CCI on some more indicators?

sebastianK

Not for now