Error compiling '1' - expression not boolean

 

Hello

I just compile an EA i am getting one error : '1' - expression not boolean


When i go to line this is the code causing the error :  if(IsStopped())return(-1);


How do i fix this?


I appreciate the help

 
When i go to line this is the code causing the error :  if(IsStopped())return(-1);

Boolean is true or false.

-1 isn't a valid return value if a boolean is expected.

 
Anthony Garot:

Boolean is true or false.

-1 isn't a valid return value if a boolean is expected.

Thank you for your reply, so i should replace it the code with this? if(IsStopped())return(false);

 
Don Calito:

Thank you for your reply, so i should replace it the code with this? if(IsStopped())return(false);

Yes, but it depends on the declaration of the procedure that you created.

https://docs.mql4.com/basis/function
https://www.mql5.com/en/docs/basis/function

Functions - Language Basics - MQL4 Reference
Functions - Language Basics - MQL4 Reference
  • docs.mql4.com
Every task can be divided into subtasks, each of which can either be directly represented in the form of a code, or divided into smaller sub-tasks. This method is called of the function definition. The function header includes a description of the return value type, name (identifier) and formal parameters.  The number of parameters passed to...
 
The return value must be the data type when you declare the function.
Eg:
int yourFunction(){
     If(something){
          return 1;//Or any integer number.
     }
}

bool yourFunction(){
     If(something){
          return true;//Or false.
     }
}
Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
  • www.mql5.com
//| Expert initialization function                                   | //| Expert deinitialization function                                 | //| Expert tick function                                             | //| test1                                                            |...
 
Yohana Parmi:

Yes, but it depends on the declaration of the procedure that you created.

https://docs.mql4.com/basis/function
https://www.mql5.com/en/docs/basis/function

I did not create the source code, i merely just compiled it and found this error. The question is do i put true or false ?

 
Don Calito:

I did not create the source code, i merely just compiled it and found this error. The question is do i put true or false ?

How can we answer with confidence if you do not display the contents of the code or function completely here :)
-- refer to https://www.mql5.com/en/forum/62715#comment_1820772

Indicator Compilation
Indicator Compilation
  • 2015.08.11
  • www.mql5.com
Hello, I want somebody to compile my EA, it was performing well until the latest update by MT4 which has reendered it useless...
 
i just posted the code, but it was removed?
 
Don Calito:
i just posted the code, but it was removed?

Nothing has been removed - you must have forgotten to hit the "Add your comment" button.