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
On Friday, October 3, 2025, an updated version of the MetaTrader 5 desktop platform will be released.
Found a casting bug:
Reference is documentation:
https://www.mql5.com/en/docs/basis/types/casting
Failing code example:
Compiler log:
NULL is not numeric. You can't and will never be able to cast NULL to an integer in MQL5.
You can't and will never be able to cast NULL to an integer in MQL5.
If this is not casting NULL to int, then what is it called?
If this is not casting NULL to int, then what is it called?
Exactly. - And, by documentation, the function-like casting is very well supported, but failing my example case.
Failing code example:
I made your example work by adding a couple of extra parentheses.
I made your example work by adding a couple of extra parentheses.
"The predefined constant variable NULL is of the void type. It can be assigned to variables of any other fundamental types without conversion. The comparison of fundamental type variables with the NULL value is allowed." (See section: Void Type and NULL Constant, MQL5 Reference)
But that only covers assignment and comparison, not its use inside arithmetic expressions or template type deduction.
In expressions or templated functions, the compiler requires a concrete type. Since NULL is of type void, it cannot be deduced as int, double, or any other numeric type, which is why the compilation error occurs.
Example only to illustrate that NULL is valid syntactically for pointer types, not for numeric use: