ReLor2:
Hi,
i have a little problem with the EMPTY_VALUE about this code.
The result is
EMPTY_VALUE is:1.7976931348623157e+308
ok->-2147483648
Why it is so, normaly i thought the "ok" part is unreachable, because value1 has EMPTY_Value, but the both values are different - im a little bit confused!?
Hi,
i have a little problem with the EMPTY_VALUE about this code.
The result is
EMPTY_VALUE is:1.7976931348623157e+308
ok->-2147483648
Why it is so, normaly i thought the "ok" part is unreachable, because value1 has EMPTY_Value, but the both values are different - im a little bit confused!?
Works correctly for me (MT4)
void OnStart() { my_function(EMPTY_VALUE); } //Function bool my_function(int value1=EMPTY_VALUE) { Print("EMPTY_VALUE is:"+EMPTY_VALUE); if(value1!=EMPTY_VALUE){ Print("ok ->"+value1); } return true; }
ReLor2: i have a little problem with the EMPTY_VALUE about this code.
For MQL5:
The constant EMPTY_VALUE is for use with the double data-type. It should not be use for integer data-types.
EMPTY_VALUE
Empty value in an indicator buffer
DBL_MAX
DBL_MAX
Maximal value, which can be represented by double type
1.7976931348623158e+308
Thank you, so i use MQL5.
I change the EMPTY_VALUE to NULL, but now i have the problem that i also dont get the wanted result.
Did i have to check the difference between NULL and zero / 0 in another way?
I change the EMPTY_VALUE to NULL, but now i have the problem that i also dont get the wanted result.
//Function bool my_function( double value1=NULL) { Print("NULL is:"+NULL); if(value1!=NULL){ Print("ok ->"+value1); } return true; } //Call the function my_function( 0);Now i want to use NULL for a kind of "nothing", i will pass in one case "nothing" so i will use "null", sometime i pass zero "0" now my if statement failed and dont print the "ok -> " part.
Did i have to check the difference between NULL and zero / 0 in another way?
ReLor2 #: Thank you, so i use MQL5. I change the EMPTY_VALUE to NULL, but now i have the problem that i also dont get the wanted result. Now i want to use NULL for a kind of "nothing", i will pass in one case "nothing" so i will use "null", sometime i pass zero "0" now my if statement failed and dont print the "ok -> " part. Did i have to check the difference between NULL and zero / 0 in another way?
Doubles are rarely equal.
// Function for double bool my_function_double( double value1 = EMPTY_VALUE ) { Print( "Empty value: ", EMPTY_VALUE ); if( value1 < EMPTY_VALUE ) Print( "ok -> ", value1 ); return true; }; // Call the function for double my_function_double( EMPTY_VALUE );

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
i have a little problem with the EMPTY_VALUE about this code.
The result is
EMPTY_VALUE is:1.7976931348623157e+308
ok->-2147483648
Why it is so, normaly i thought the "ok" part is unreachable, because value1 has EMPTY_Value, but the both values are different - im a little bit confused!?