It will not be realized in the near future
Hi William,
even if the official response is "don't hold your breath",
I'm entirely with you on this feature request!
Cheers
I'd love to see it too. It would be very easy to write a script in MQL5 which deletes debug code for a release version of an EA, like this.
#define DEBUG_CODE
//#ifdef DEBUG_CODE
// ... debug stuff in original EA to delete in the release version
//#endif
As far as the #define functoin call goes, C++ has inlining for functions declared in the include file inside the class. If MQL5 has this feature then it is better than #define because the compiler performs type-checking. It would be great to have some documentation of optimiser behaviour such as this: does MQL5 support true inlining, ie overhead-free function calls, particularly for get/set functions?
Paul
I'd love to see it too. It would be very easy to write a script in MQL5 which deletes debug code for a release version of an EA, like this.
#define DEBUG_CODE
//#ifdef DEBUG_CODE
// ... debug stuff in original EA to delete in the release version
//#endif
As far as the #define functoin call goes, C++ has inlining for functions declared in the include file inside the class. If MQL5 has this feature then it is better than #define because the compiler performs type-checking. It would be great to have some documentation of optimiser behaviour such as this: does MQL5 support true inlining, ie overhead-free function calls, particularly for get/set functions?
Paul
There is a macro "IS_DEBUG_MODE", below code shows how you can use it
{
// This code will be executed only in debug build.
// In the release build the optimizer will cut IF statement
}
Documentation will be as soon as the work on the optimizer will be finished
I like MT5 very much, especially on the debugger. But right now it is slow and unstable, so in the meantime, I ported my MT4 codes over to MT5 and able to use the debugger. For most parts I can use functions to encapsulate the differences but others (example the extern and input keywords for indicator parameters) I have to include 2 codes and comment out the MT5 codes when I compile in MT4 and vice versa. This is becoming tedious.
I would like to ask for a conditional inclusion preprocessor directives (#ifdef, #ifndef, #if, #endif, #else and #elif) to help to maintain single code base for both MT4 and MT5.
Besides using it for the above purpose, it could be used to optimise simple functions without actually incurring an expensive function call during run time. For example:
#define getmax(a,b) a>b?a:b
It's not clear how to define and use it (I could not discovery it), but there is a news here about this topic:
72272
MetaTrader 5 Client Terminal build 871
- MQL5: Fixed an issue that prevented testing of experts containing custom indicators in the form of a resource . Error affected including experts from MQL5 Market.
- MQL5: Added support for conditional compilation # if [n] def, # else and # endif.
If someone has an complete example using the new resource of conditional compilation please publish the source code here.

- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
I like MT5 very much, especially on the debugger. But right now it is slow and unstable, so in the meantime, I ported my MT4 codes over to MT5 and able to use the debugger. For most parts I can use functions to encapsulate the differences but others (example the extern and input keywords for indicator parameters) I have to include 2 codes and comment out the MT5 codes when I compile in MT4 and vice versa. This is becoming tedious.
I would like to ask for a conditional inclusion preprocessor directives (#ifdef, #ifndef, #if, #endif, #else and #elif) to help to maintain single code base for both MT4 and MT5.
Besides using it for the above purpose, it could be used to optimise simple functions without actually incurring an expensive function call during run time. For example:
#define getmax(a,b) a>b?a:b