I wish to get some feedback from other coders/developers on their experiences and workflow process with regards to projects written to be both MQL5 and MQL4+ compatible.
For the past few years, I have being coding in a way that all my Indicators and EAs make use of conditional compilation, so that the code will compile and run on both MT4 and MT5 systems. It all works relatively well, but I find myself having to store files in duplicate form sometimes due to two main factors:
- The first being, of having to have different file extensions for the same file for the two systems (namely “.mq4” and “.mq5”).
- The second being that I use OneDrive to synchronise and backup files between devices and the cloud, which is all good and well, but It does not play nice with symbolic or hard links between files within its own folder space. For example, I can store the file with “.mq5” and then create a link for the “.mq4” file, but OneDrive does not like that.
For point (2), I simply don’t have a solution, OneDrive allows links to/from files outside of its folder space but not within its own folder space. I also do not plan to use other Cloud systems like DropBox, because I already have 1TB space included in my Office license and don’t wish to pay extra or have to run two systems on my PCs eating away at resources. I also don’t wish to use Git for this because I don’t have much need for version control and I find it a hassle to always have to manage the commits when I make changes. OneDrive does a decent job of keeping a version history of the file updates automatically and I rarely need to make use of it, so I don’t need the complexity of Git for my MQL code.
When I have large projects and need to make use of the “Project” system of MetaEditor, the issues become quite more complex since I need to duplicate all the project files due to points (1) and (2), which is a pain.
So, my question to all coders/developers that work in a similar fashion of maintaining single-source for both MQL5 and MQL4+, how to you go about it in respect to your personal workflow habits?
Have you tried having a variable that says what version you are at runtime. Then having each function go from there? I have some old code somewhere, but not sure I can find it. Not really the solution you are looking for, but that's how I dealt with it.
Sorry, but I really don't see the relevance of your post! I don't need help with coding. There are already conditional compilation rules defined in MQL. I have no need for the creation of any special "variables" or "versioning"! My query is about workflow and file-handling for maintaining a single-source environment without the file duplication between the two systems.
I wish to get some feedback from other coders/developers on their experiences and workflow process with regards to projects written to be both MQL5 and MQL4+ compatible.
For the past few years, I have being coding in a way that all my Indicators and EAs make use of conditional compilation, so that the code will compile and run on both MT4 and MT5 systems. It all works relatively well, but I find myself having to store files in duplicate form sometimes due to two main factors:
- The first being, of having to have different file extensions for the same file for the two systems (namely “.mq4” and “.mq5”).
- The second being that I use OneDrive to synchronise and backup files between devices and the cloud, which is all good and well, but It does not play nice with symbolic or hard links between files within its own folder space. For example, I can store the file with “.mq5” and then create a link for the “.mq4” file, but OneDrive does not like that.
For point (2), I simply don’t have a solution, OneDrive allows links to/from files outside of its folder space but not within its own folder space. I also do not plan to use other Cloud systems like DropBox, because I already have 1TB space included in my Office license and don’t wish to pay extra or have to run two systems on my PCs eating away at resources. I also don’t wish to use Git for this because I don’t have much need for version control and I find it a hassle to always have to manage the commits when I make changes. OneDrive does a decent job of keeping a version history of the file updates automatically and I rarely need to make use of it, so I don’t need the complexity of Git for my MQL code.
When I have large projects and need to make use of the “Project” system of MetaEditor, the issues become quite more complex since I need to duplicate all the project files due to points (1) and (2), which is a pain.
So, my question to all coders/developers that work in a similar fashion of maintaining single-source for both MQL5 and MQL4+, how to you go about it in respect to your personal workflow habits?
Putting aside my OneDrive issue, how do you handle large projects with multiple ".mq5" files?
Ideally one would just need one hard-link for the entire folder tree, but that does not seem possible if one then needs extra separate hard-links for each ".mq5"->".mq4" file. Do you maintain multiple individual hard links for each ".mq5"->".mq4" file for such large projects?
It would be great if one could just instruct MetaEditor to compile to a certain target (MQL5/MQL4) irrespective of the file extension.
EDIT: For a large project, for example with multiple Indicators and an Expert as well, where there would be several ".mq5" files.
Putting aside my OneDrive issue, how do you handle large projects with multiple ".mq5" files?
Ideally one would just need one hard-link for the entire folder tree, but that does not seem possible if one then needs extra separate hard-links for the ".mq5"->".mq4" file. Do you maintain multiple individual hard links for each ".mq5"->".mq4" file for such large projects?
It would be great if one could just instruct MetaEditor to compile to a certain target (MQL5/MQL4) irrespective of the file extension.
I don't use MetaEditor "Project", it's not flexible and buggy from my point of view. So yes I am creating a hard link for each mq5/mq4 file. I have a tool to do that which is pretty easy to use.
"Shared Folders"? You mean, MQL's "Shared Projects" where you can have other users view the files as well through "MQL's Storage" solution?
"Shared Folders"? You mean, MQL's "Shared Projects" where you can have other users view the files as well through "MQL's Storage" solution?
- 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.- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
You agree to website policy and terms of use
For the past few years, I have being coding in a way that all my Indicators and EAs make use of conditional compilation, so that the code will compile and run on both MT4 and MT5 systems. It all works relatively well, but I find myself having to store files in duplicate form sometimes due to two main factors:
For point (2), I simply don’t have a solution, OneDrive allows links to/from files outside of its folder space but not within its own folder space. I also do not plan to use other Cloud systems like DropBox, because I already have 1TB space included in my Office license and don’t wish to pay extra or have to run two systems on my PCs eating away at resources. I also don’t wish to use Git for this because I don’t have much need for version control and I find it a hassle to always have to manage the commits when I make changes. OneDrive does a decent job of keeping a version history of the file updates automatically and I rarely need to make use of it, so I don’t need the complexity of Git for my MQL code.
When I have large projects and need to make use of the “Project” system of MetaEditor, the issues become quite more complex since I need to duplicate all the project files due to points (1) and (2), which is a pain.
So, my question to all coders/developers that work in a similar fashion of maintaining single-source for both MQL5 and MQL4+, how to you go about it in respect to your personal workflow habits?