High CCI

 

Hi all. I was recently experimenting with the highest function and the icci function. what i am intending to do is to find the highest point of the cci back about 6 bars, starting one bar back. it compiles perfectly, but the problem is that when i run it through the tester i get weird numbers, which should actually be in the hundreds. check it out!

2006.12.12 19:56:58 2004.01.12 11:06 Power Bit EA v1 EURUSD,Daily: CCI2 = 1.29

here's the string of code being used.

double CCI2 = High; Print("CCI2 = ",CCI2);

just so everyone knows, CCIPERIOD is an integer i assigned to 14 in my global variables.

 

any coders out there have an answer to this problem???

 

I believe you have to use iCCIOnArray as iHighest works on arrays.

 
asmdev:
Value is fine. Description of iHighest http://docs.mql4.com/series/iHighest

'iHighest' returns highest bar and 'High' its value.

iCCI has nothing to do with iHighest

ok. that's been one thorn of confusion in my side, with the whole, "Returns shift". which i've kinda guessed how to figure out.

do you happen to know a way i can return the highest point of a cci?

 

Value is fine. Description of iHighest http://docs.mql4.com/series/iHighest

'iHighest' returns highest BAR and 'High' its value.

iCCI has nothing to do with iHighest

if you want highest iCCI you need a loop, looping from starting bar util the end

 
Maji:
I believe you have to use iCCIOnArray as iHighest works on arrays.

Thanks for the reply. I appreciate your input everyone.

so your saying something like this?

High;

and that will give me the highEST point back 5 bars

 
asmdev:
if you want highest iCCI you need a loop, looping from starting bar util the end

Thanks for the speedy replies everyone.

so in other words, i have to create a custom array?

boy oh boy. looks like no matter how hard i try, i have to use an array at least somewhere. (a friend of mine loves arrays but they take too long for me to program sometimes)

 
Eaglehawk:
find the highest point of the cci back about 6 bars, starting one bar back

double maxVal = -99999;

for(int i=0; i>=5; i++) maxVal = MathMax(maxVal, iCCi(NULL,0,CCIPERIOD,MODE_CLOSE,i) );

//maxVal is your highest cci value at the end of loop.

 

double maxVal = -99999;

int bar = 0;

for(int i=0; i>=5; i++){

double cci = iCCi(NULL,0,CCIPERIOD,MODE_CLOSE,i) ;

if(cci > maxVal){

bar = i;

maxVal = cci;

}

}

"bar" is the bar where cci is max and maxVal is your highest cci at the "bar".

I never used iCCIOnArray but you can give it a try. You'll need to define array somewhere.

 
asmdev:
double maxVal = -99999;

for(int i=0; i>=5; i++) maxVal = MathMax(maxVal, iCCi(NULL,0,CCIPERIOD,MODE_CLOSE,i) );

//maxVal is your highest cci value at the end of loop.

wow! let me tell you. with so many people pointing me back to a "math" function like mathmod, mathmax, i think that should be my next area of study, lol.

Thanks for your assistance, it's nice to learn new functions like this. every once in a while, several problems wash away from one answer. I LOVE IT!

 
asmdev:
double maxVal = -99999;

int bar = 0;

for(int i=0; i>=5; i++){

double cci = iCCi(NULL,0,CCIPERIOD,MODE_CLOSE,i) ;

if(cci > maxVal){

bar = i;

maxVal = cci;

}

}

"bar" is the bar where cci is max and maxVal is your highest cci at the "bar".

I never used iCCIOnArray but you can give it a try. You'll need to define array somewhere.

That's pretty ingenious. That answers my question too...

https://www.mql5.com/en/forum/175614/page4

Reason: