Accelerator EA (green or not)

 

Hi guys!!

I planned to use the AC indicator in my EA. I want to know if the current bar on the AC is green or red. I also found out that it is green if the current value is of higher value than the previous bar. Which also means that the bar will be red if the current bar has lesser value than the previous bar.

This is the code I was using :

double CurrentAC = iAC(NULL, 0, 0);
double PreviousAC = iAC(NULL, 0, 1);

After that code I compare the too with each other:

if (CurrentAC > PreviousAC) Print("AC is Green");
else Print("AC is Red, ", CurrentAC, ", ", PreviousAC);

When I run this EA it prints that the AC is Red every single time. It seems like it has difficulties either getting the previous value of AC or comparing the two double variables with each other.

Can you guys give me a hand on this one? Would really appreciate if somebody could help me getting this EA done!

Thanks

YoungMoney

 
If this code is in start() and you are running it for every tick then it will print the same message for every tick . . it may change when you get a new bar . . . perhaps you should run this code at the start of a new bar ?
 
RaptorUK:
If this code is in start() and you are running it for every tick then it will print the same message for every tick . . it may change when you get a new bar . . . perhaps you should run this code at the start of a new bar ?


Yeah I am running it at the start()..

How do I make it run for every new bar?

 
RaptorUK:
If this code is in start() and you are running it for every tick then it will print the same message for every tick . . it may change when you get a new bar . . . perhaps you should run this code at the start of a new bar ?


Also it seems like this code isn't getting the right amount of decimals..

How do I get a larger amount of decimals in my double variables?

 

Hi YoungMoney,

Try this ?

if (CurrentAC > PreviousAC) 
  {
  Print("AC is Green");
  }
  else
  {
  if (CurrentAC < PreviousAC)
     {
     Print("AC is Red");
     }
     else
     {
     Print ("AC is L.O.L");
     }
  }

Who knows it won't work

:D

 
YoungMoney:


Also it seems like this code isn't getting the right amount of decimals..

How do I get a larger amount of decimals in my double variables?

Did you read this ? Print()
Reason: