if( cond1 && cond2){ return 1; } if(cond3){ return 2; } // what are you returning here?
None needed.
if() A; else B; C;
means do A or B then do C. If A is a return, break, or continue, there is no C in that case. Simplify to if() return; B; C.
If the B is a return, break, or continue, there is no C in that case. Simplify to if(not condition) return; A; C.
I just would like to return integers, 1 and 0 and thats it.
int function1(int signal){
if(cond1 && cond2){
return 1;}
else if(cond3){
return 0;}
}
-
Please edit your posts and use the CODE button (or Alt+S)! (For large amounts of code, attach it.)
General rules and best pratices of the Forum. - General - MQL5 programming forum #25 (2019)
Messages Editor
Forum rules and recommendations - General - MQL5 programming forum (2023) - tradefy #: I just would like to return integers, 1 and 0 and thats it.
int function1(int signal){ if(cond1 && cond2){ return 1;} else if(cond3){ return 0;} // again what are you returning here? }
Again, if your first if is false, there is no else (or else if) needed.
int function1(int signal){ if(cond1 && cond2){ return 1;} if(cond3){ return 0;} return 99; }
You need to have a return value outside the if statements in a function,
If non of the cond are true, then the function need to return something,
Hy guys, simple question and don't know what its wrong here. Please have a look:
This is very basic. The program needs a "default return value" incase neither ( cond1 && cond2 ) or (cond3) are true. Update to:
int function1(){ if(cond1 && cond2)return 1; if(cond3) return 0; else return -1; // the return 1 is for buy signal , 0 for neutral and -1 is undefined }
if neither of the conditions are true program returns -1 as default value.
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
Warning: '}' - not all control paths return a value
Thanks for your support!