What is your workflow for maintaining single-source code files between MQL5 and MQL4+ projects? - page 2

 
Doerk Hilger:

- I am using two different installations, one for MT5, one for MT4. 

- I avoid the .mq4 and .mq5 extensions for real code and always create .mqh files which are just included in these .mq4/.mq5. This way I avoid double coding

- I packed all native MQL commands into a separate file, so that the almost all conditions like #ifdef __MQL4__ are located in one single file

- I packed all trade relevant code into a separate file and created a class which allows for trading with MT4/MT5 by providing the same functions

- Coding is done only within MT5 environment

- To synchronize / copy changes to the MT4 instance, I use the FreeFileSync app. After changes within MT5 code, it needs one click to update the whole MT4 folder-strcuture. Within MT4 I just compile, never edit. To update from MT5 to MT4 and to re-compile the complete stuff, which contains far more than 100 files, it takes less than 3 minutes. 

The process works reliable and without any issues since years.
Thanks!
 
Fernando Carreiro:
Thanks!

Welcome :) 

 

Here are a few updates for your information, should it be of interest to anyone:

OneDrive Hard-Links:

It seems the newer versions of OneDrive no longer causes conflicts with hard links within its own folder space. So, I will be able to use this improve my workflow. As a test I decided to create a common MQL folder (within the OneDrive folder space) with the same structure as MQL4 and MQL5 folders and using an extension of “.mql” as the common source and creating hard-links for both “.mq5” and “.mq4” versions (also within OneDrive folder space).

OneDrive accepted them without issues or errors, but only the “.mql” source was replicated to the cloud. The “.mq5” and “.mq4” hard-links were not replicated to the cloud. Which means that replication of these will not take place between devices. However, the compiled “.ex4” and “.ex5” files were replicated as they are just standard files. I can live with this, since I only do development on one machine, my main PC.

Editing and Compiling both MQL4 and MQL5 from a single MetaEditor:

One curious thing that I found, was that the MetaEditor opened via MetaTrader 4, which is the 32-bit version (build 2376), will both edit and compile both MQL4 and MQL5 files, producing both “.ex4” and “.ex5” files, without any issues. Which is great because I can handle both platforms from a single application.

However, the MetaEditor opened via MetaTrader 5, which is the 64-bit version (build 2875), will edit both types always as if being MQL5 and will not compile the “.mq4” files, reporting an “Unsupported file extension” error, which means I am unable to handle both types from this single application, which is a pity, as I was planning to structure things so I would do everything from the 64 bit MetaEditor.

I don’t know if the difference in the handling was due the different builds or if the difference is due to them being 32-bit and 64-bit respectively.  

I also tried seeing if they would compile “.mql” files, but as expected, it gave an “Unsupported file extension” error! It does however edit them as being MQL5 files.

 
Fernando Carreiro:

Here are a few updates for your information, should it be of interest to anyone:

...

Editing and Compiling both MQL4 and MQL5 from a single MetaEditor:

One curious thing that I found, was that the MetaEditor opened via MetaTrader 4, which is the 32-bit version (build 2376), will both edit and compile both MQL4 and MQL5 files, producing both “.ex4” and “.ex5” files, without any issues. Which is great because I can handle both platforms from a single application.

However, the MetaEditor opened via MetaTrader 5, which is the 64-bit version (build 2875), will edit both types always as if being MQL5 and will not compile the “.mq4” files, reporting an “Unsupported file extension” error, which means I am unable to handle both types from this single application, which is a pity, as I was planning to structure things so I would do everything from the 64 bit MetaEditor.

I don’t know if the difference in the handling was due the different builds or if the difference is due to them being 32-bit and 64-bit respectively.  

I also tried seeing if they would compile “.mql” files, but as expected, it gave an “Unsupported file extension” error! It does however edit them as being MQL5 files.

mql4 compilation is no more supported with the new MT5 MetaEditor build (maybe 6 months ago ? I don't remember exactly).

MT5 32 bit support is stopped. So I suppose you can compile ex5 with the MT4 version of MetaEditor but I don't think you will be able to use it, and for sure you will not benefit from the last mql5 features (and bugs loool).

 
Alain Verleyen: So I suppose you can compile ex5 with the MT4 version of MetaEditor but I don't think you will be able to use it, and for sure you will not benefit from the last mql5 features (and bugs loool).
I tested the ".ex5" file compiled by MetaEditor build 2376 (32-bit), and it worked without issue on MetaTrader 5 build 2875 (64-bit). So, for the current version it still works. It might fail in the future.