How to compile two versions of the program at the same time

 

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. 

 
Make two versions. One code is one.
 
Narek Kamalyan:

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
  }
 
Samuel Manoel De Souza #:

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?
 
Narek Kamalyan #:
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.

Documentation on MQL5: Language Basics / Preprocessor / Macro substitution (#define)
Documentation on MQL5: Language Basics / Preprocessor / Macro substitution (#define)
  • www.mql5.com
Macro substitution (#define) - Preprocessor - Language Basics - MQL5 Reference - Reference on algorithmic/automated trading language for MetaTrader 5
 
Samuel Manoel De Souza #:

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.
 
ifeany1 #:
Please where can I get someone to code a trading indicator with alert? Something that work on TradingView and another that works on MT5.

https://www.mql5.com/en/job

Trading applications for MetaTrader 5 to order
Trading applications for MetaTrader 5 to order
  • 2021.12.06
  • www.mql5.com
The largest freelance service with MQL5 application developers
 
Narek Kamalyan #:

https://www.mql5.com/en/job

thank you
Reason: