Download MetaTrader 5

Error of " '}' - not all control paths return a value"

To add comments, please log in or register
Publish your article and thousands of people all over the world will read it!
Antoine
92
Antoine 2010.11.15 14:33 

Hello,

I meet a problem when I try to compile my EA, it return me a error message " '}' - not all control paths return a value" .

How can I solve it??

investeo
4098
investeo 2010.11.15 14:54  
Antoine:

Hello,

I meet a problem when I try to compile my EA, it return me a error message " '}' - not all control paths return a value" .

How can I solve it??

 

 

look in every condititional statement, or paste the function
Antoine
92
Antoine 2010.11.15 15:42  

I will paste it tonight, I can't do it now.

Thank you.

Antoine
92
Antoine 2010.11.15 23:34  
See attach my EA:

Pawel Wojnarowski
685
Pawel Wojnarowski 2010.11.16 01:23  
Antoine:
See attach my EA:

Your problem is quite easy - your main function is int OnCalculate and, as it is declared as function returning an integer (int) value, it should return such value at the end of function body. OnCalculate should return rates_total:

...
      CANDLE_STRUCTURE cand3;
         cand3=cand2;
         cand2=cand1;
         if(!RecognizeCandle(_Symbol,_Period,time[i-2],InpPeriodSMA,cand1))
            continue;
         bool Buy_Condition_1 = (cand3.trend==DOWN && !cand3.bull);
         bool Buy_Condition_2 = (cand3.type==CAND_LONG || cand3.type==CAND_MARIBOZU || cand3.type==CAND_MARIBOZU_LONG);     
      }   
      return(rates_total); // this is what your code was lacking
  }
To add comments, please log in or register