I need to make the program to automatically compile two versions, for example with different default input parameters.
Or lets say I have funcion1 and function2. I would like to create two versions of the EA while compiling, first of which will be running funcion1, the second version function2 respectively.
Use defines. actually you still will have to compile 2 times, but you can have everything in one file and the difference between the 2 versions will be just one line.
Program 1:
#define program1 //#define programa2 //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void some_function(void) { #ifdef program1 // do something #else #ifdef program2 // do something #endif #endif }
Program 2:
//#define program1 #define programa2 //+------------------------------------------------------------------+ //| | //+------------------------------------------------------------------+ void some_function(void) { #ifdef program1 // do something #else #ifdef program2 // do something #endif #endif }
Use defines. actually you still will have to compile 2 times, but you can have everything in one file and the difference between the 2 versions will be just one line.
Program 1:
Program 2:
Samuel, in your example I have to change the program1 to program2 before compiling the new version right? If it is the case, then I can use any variable to put the condition. What is the advantage of define?
Check documentation.
https://www.mql5.com/en/docs/basis/preprosessor/constant
What it does is tell to compiler what should be compiled. Isn't a conditional to be checked at runtime.
- www.mql5.com
Check documentation.
https://www.mql5.com/en/docs/basis/preprosessor/constant
What it does is tell to compiler what should be compiled. Isn't a conditional to be checked at runtime.
In other words, the piece of code which is no defined by identifier will not be included in the compiled file.
Please where can I get someone to code a trading indicator with alert? Something that work on TradingView and another that works on MT5.
- 2021.12.06
- www.mql5.com
- 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 need to make the program to automatically compile two versions, for example with different default input parameters.
Or lets say I have funcion1 and function2. I would like to create two versions of the EA while compiling, first of which will be running funcion1, the second version function2 respectively.