If / Then on Current CCI(20)

Posted By: Metzenovich

If / Then on Current CCI(20) - 03/26/21 17:17

Hi,

I'm trying to take different actions based on the current CCI(20).

Code
vars CCIs = series(CCI(20));
if(CCIs[0] >= 0.0){
plot("CCI", 150, SQUARE, GREEN);
}else{
plot("CCI", 150, SQUARE, RED);
}


But all of the squares are red, regardless of the CCI.

I tried this as well, with the same result:
Code
if(CCI(20) >= 0.0){


I'm expecting some of the squares to be red and some to be green, based on the CCI(20) at the time.

If I print out the value it looks like I expect, some above 0, some below:
Code
printf("\nCCI: %.4f", CCI(20));


I'm sure I'm just missing something simple...

Thanks!
Posted By: jcl

Re: If / Then on Current CCI(20) - 03/26/21 18:15

Yes. Name the plots "CCIRED" and "CCIGREEN". Otherwise the red will be angry at the green when it has the same name.
Posted By: Metzenovich

Re: If / Then on Current CCI(20) - 03/26/21 20:23

Thanks! I knew the type (SQUARE, DOT, etc) couldn't be changed within a given plot name, but didn't realize that applied to the color as well.
© 2024 lite-C Forums