Multiple MQ4 files in an EA

 

I am brand new to MT4, and am required to use MT4 instead of MT5 because OANDA my broker only supports MT4.

I am a C/C++/C# expert.

Questions:

Using the MetaEditor I do not see a way to organize a set of files into a project.   It looks like EA's must be 1 file and only 1 file?   Is there a way to create a project where I would have multiple mq4 files in a single EA program?

Thanx

Bodger

 
Bodger: I am brand new to MT4, and am required to use MT4 instead of MT5 because OANDA my broker only supports MT4.I am a C/C++/C# expert.

Questions: Using the MetaEditor I do not see a way to organize a set of files into a project.   It looks like EA's must be 1 file and only 1 file?   Is there a way to create a project where I would have multiple mq4 files in a single EA program?

It is not very common to have EA's that span more than a single source file, but it is possible to have "Projects" (see image), but you will have to active MQL5 Storage (in your Profile) for using these Subversion-based "Projects" ...


EDIT: PS! Please note that you do not have to "activate" this to develop multi-file EA projects. You can create your own Projects File structure and develop them as you wish without "activating" it. The MQL5 Storage, just simplifies things by adding versioning and cloud-storage in order to facilitate the development of projects, especially when working in teams.

Also, please note that the MetaEditor is v5.0, as it is used for both the MetaTrader 4 and MetaTrader 5 environments.

MQL5 Storage - MetaEditor Help
MQL5 Storage - MetaEditor Help
  • www.metatrader5.com
The MQL5 Storage is a personal MQL4/MQL5 source codes repository designed for the versioned storing of files and handy project management directly from MetaEditor. The main advantages of using the MQL5 Storage: Access to the storage from any computer. You can log in MetaEditor using your MQL5.community account...
 

Hi Bodger, 

You will want to use mqh files and include them into you main mq4. For example, let's say I wanted to start an open-source project and have all the related files in one folder/repo. First I would create a subfolder in the Experts folder. Next I would run git init and create a repo. After that I copy all the mqh dependencies into that folder. Here is an example: https://bitbucket.org/nicholishen/mql4-ffevents/src  

 

You can share source code with indicators by using a relative path with the includes

#include "../../Indicators/MyCodebase/MyCalc.mqh"
 
Bodger:

I am brand new to MT4, and am required to use MT4 instead of MT5 because OANDA my broker only supports MT4.

I am a C/C++/C# expert.

Questions:

Using the MetaEditor I do not see a way to organize a set of files into a project.   It looks like EA's must be 1 file and only 1 file?   Is there a way to create a project where I would have multiple mq4 files in a single EA program?

Thanx

Bodger

This doesn't really answer your question of "Using the MetaEditor . . . " but it may be a useful work-around.

metaeditor.exe will take command-line options, which means you could, with a little work, get an IDE of your choice (e.g. Eclipse) to compile your MQL4 code.

https://www.metatrader5.com/en/metaeditor/help/development/compile

When I did MQL4 code, I used SciTE editor for MQL4:

http://ylw633.github.io/scite-mql/

SciTE for MQL4 doesn't really do "projects," per se, but you can save sessions, which allow you to group related files. It's better than nothing.

It wasn't too hard to outfit SciTE for MQL5, either.

 
Anthony Garot:

This doesn't really answer your question of "Using the MetaEditor . . . " but it may be a useful work-around.

metaeditor.exe will take command-line options, which means you could, with a little work, get an IDE of your choice (e.g. Eclipse) to compile your MQL4 code.

...

What would be the advantage of compiling MQL from Eclipse when you do not have any integration in Eclipse?

 
Ex Ovo Omnia:

What would be the advantage of compiling MQL from Eclipse when you do not have any integration in Eclipse?

Advantages include:

1. To organize a set of files into a project. This becomes especially useful when a programmer puts each class in a separate file. It becomes even more useful when unit tests are also added.

2. Eclipse is extensible through plugins. For example, EGit gives you git access from within the IDE.

It should be fairly straightforward to convert a C++ code template to MQL, so you wouldn't miss out on syntax coloring.

All that said, I use SciTE for all my MQL programming, not Eclipse; but it could be used if a programmer wanted additional features.

 
Anthony Garot:

Advantages include:

1. To organize a set of files into a project. This becomes especially useful when a programmer puts each class in a separate file. It becomes even more useful when unit tests are also added.

2. Eclipse is extensible through plugins. For example, EGit gives you git access from within the IDE.

It should be fairly straightforward to convert a C++ code template to MQL, so you wouldn't miss out on syntax coloring.

All that said, I use SciTE for all my MQL programming, not Eclipse; but it could be used if a programmer wanted additional features.

Just as a side note, the free "Microsoft Visual Studio Code" or even its big brother, but still free "Visual Studio (Community Edition)", can also achieve this and already has a MQL 4 & 5 extension available.
 
Anthony Garot:

Advantages include:

1. To organize a set of files into a project. This becomes especially useful when a programmer puts each class in a separate file. It becomes even more useful when unit tests are also added.

2. Eclipse is extensible through plugins. For example, EGit gives you git access from within the IDE.

It should be fairly straightforward to convert a C++ code template to MQL, so you wouldn't miss out on syntax coloring.

All that said, I use SciTE for all my MQL programming, not Eclipse; but it could be used if a programmer wanted additional features.

It is hard to discuss the topic with you, as you do not have any experience with any IDE like Eclipse (sorry, but Scite is a simple text editor with syntax highlighting, but no way it is IDE). Adding support for a language like MQL into IDE would be quite expensive project, consuming multiple man-years.

BTW, what prevents you from saving every class into a dedicated file in Metaeditor?
 
Ex Ovo Omnia:

It is hard to discuss the topic with you, as you do not have any experience with any IDE like Eclipse (sorry, but Scite is a simple text editor with syntax highlighting, but no way it is IDE). Adding support for a language like MQL into IDE would be quite expensive project, consuming multiple man-years.

BTW, what prevents you from saving every class into a dedicated file in Metaeditor?

You should try SciTE. It's pretty good for a text editor.

I also use VIM sometimes. It was pretty easy to create a .vim file for syntax highlighting. VIM is way more powerful as an editor, but I've gotten used to SciTE.

Good luck

 
Anthony Garot:

You should try SciTE. It's pretty good for a text editor.

I also use VIM sometimes. It was pretty easy to create a .vim file for syntax highlighting. VIM is way more powerful as an editor, but I've gotten used to SciTE.

Good luck


Do you still use SciTe? I doubt, as it has not much sense. I had been using SciTe extensively until 2014, and the difference between Metaeditor and Scite was rather cosmetic. Both were simple text editors with a few added features. However MQL4 implemented OOP in 2014 and the SciTe project for MQL died with lack of the OOP syntax support. Moreover, every such a project needs sustained maintenance, which was also problem with MQL for SciTe.

Reason: