function error

Luandre Ezra
215
Luandre Ezra  

Hi everyone I have this simple code function that give me an error message "'}' - not all control paths return a value"

bool GreenCandle(int shift = 0)
  {
   if(iOpen(Symbol(),PERIOD_CURRENT,shift) < iClose(Symbol(),PERIOD_CURRENT,shift)) return true;
  }

I have a return value but why it gives me an error of return value, anyone knows how to fix it?

Paul Anscombe
5511
Paul Anscombe  
Luandre Ezra:

Hi everyone I have this simple code function that give me an error message "'}' - not all control paths return a value"

I have a return value but why it gives me an error of return value, anyone knows how to fix it?

You declared it as a function that returns a boolean so ensure that all paths through the code end with a boolean returned.

If the IF statement is false what happens = no declared value for the return in your code.

bool GreenCandle(int shift = 0)
  {
   if(iOpen(Symbol(),PERIOD_CURRENT,shift) < iClose(Symbol(),PERIOD_CURRENT,shift)) return(true);

   return(false);
  }