Using MQL5 Standard Library in MQL4

 

Hi all,

I have been working primarily on MT4 which has undoubtedly the broadest support among my brokers, only a couple offer MT5 and not necessarily with the same instruments I want to trade with my algorithms. Recently I started delving much deeper into MQL5 and its standard library classes for developing Expert Advisors -- https://www.mql5.com/en/docs/standardlibrary/expertclasses

Searching on Google, I found surprisingly very little good material about this OOP framework for EA development, which is included with MT5 by default for almost a decade now -- this gives me some concerns to be honest. I would very much appreciate if someone can point to the best resources to learn how to use this effectively... Thus far I found some articles that discuss these modules but am still finding it somewhat confusing, so I generated a sample with the EA Wizard and am currently exploring the code and cross-checking the Online Help.

Before I dive all in, full steam ahead, can anyone comment on how robust and bug-free is this EA development framework?  Also, very importantly, how difficult would it be to backport this set of classes to MQL4 for use in MT4? I realise that the actual order/position management part is significantly between the two versions, so CTrade and CExpertTrade would need to be adjusted accordingly or large parts rewritten. I am keen to understand what else might I be missing, surely I am not the first to think going down this path but, as I said above, found relatively little discussed on the subject in these forums or other websites.

Thanks in advance, /dima

PS: My main goal here is to leverage a mature, stable development framework that will allow me to speed up writing EAs, from quick prototypes for evaluating new tradings ideas to building production-grade bots to trade live.

Documentation on MQL5: Standard Library / Strategy Modules
Documentation on MQL5: Standard Library / Strategy Modules
  • www.mql5.com
This section contains technical details of working with classes for creation and testing of trading strategies and description of the relevant components of the MQL5 standard library.
 
ddiall:

Hi all,

I have been working primarily on MT4 which has undoubtedly the broadest support among my brokers, only a couple offer MT5 and not necessarily with the same instruments I want to trade with my algorithms. Recently I started delving much deeper into MQL5 and its standard library classes for developing Expert Advisors -- https://www.mql5.com/en/docs/standardlibrary/expertclasses

Searching on Google, I found surprisingly very little good material about this OOP framework for EA development, which is included with MT5 by default for almost a decade now -- this gives me some concerns to be honest. I would very much appreciate if someone can point to the best resources to learn how to use this effectively... Thus far I found some articles that discuss these modules but am still finding it somewhat confusing, so I generated a sample with the EA Wizard and am currently exploring the code and cross-checking the Online Help.

Before I dive all in, full steam ahead, can anyone comment on how robust and bug-free is this EA development framework?  Also, very importantly, how difficult would it be to backport this set of classes to MQL4 for use in MT4? I realise that the actual order/position management part is significantly between the two versions, so CTrade and CExpertTrade would need to be adjusted accordingly or large parts rewritten. I am keen to understand what else might I be missing, surely I am not the first to think going down this path but, as I said above, found relatively little discussed on the subject in these forums or other websites.

Thanks in advance, /dima

PS: My main goal here is to leverage a mature, stable development framework that will allow me to speed up writing EAs, from quick prototypes for evaluating new tradings ideas to building production-grade bots to trade live.

Hi,

You may be interested in the https://www.mql5.com/en/code/25104

It is a library that creates EAs in cross-platform way.  I have used it in production environment. 

Also, it is open source, so you can contribute to further development if you like.

MQL_Easy
MQL_Easy
  • www.mql5.com
MQL_Easy is an open source cross platform library for developing MQL4 and MQL5 applications. The purpose of this library is to make the mql development easy, safe and fast in order to focus more on implementing complex trading ideas. The cross platform property assure that the same piece of code works on both platforms. In addition, it has...
 
ddiall: how difficult would it be to backport this set of classes to MQL4 for use in MT4?

Much harder than you imagine. The underlying trading paradigm is different on non-hedging accounts.

 
William Roeder #:

Much harder than you imagine. The underlying trading paradigm is different on non-hedging accounts.

Hi William,

Thanks for your response. I am transitioning to work on MQL5 exclusively going forward and re-assessing whether to use the Standard Library...  I really like the OOP-based concept for building bots by composing objects representing experts, signals, filters, indicators, risk managers, etc and have been studying the various classes CExpert, CExpertSignal, CExpertMoney, and so on. In fact, I was even using similar OOP approaches in my projects in MQL4, depending on specific requirements.

I can see going this route to be very helpful to fast-track prototyping/testing new trading strategy ideas, before committing to a full R&D cycle to bring it to production. However, simultaneously I am a little bit apprehensive about going full in by not seeing more evidence searching online and in these forums about large-scale adoption of this "new" Standard Library, considering that MT5 has been released over 10 years by now -- albeit I am unsure when the library when the library was first introduced.

The documentation of the library itself is not particularly great -- it's really just reference material, no developer guide nor many published about its usage & best practice as for many other topics by MetaQuotes and the MQL community. In any case, with a solid experience using MT4/MT5 and coding in MQL, it's possible to get one's head around the library's concept and architecture by reading the code itself.

Moreover, another aspect raising my concerns further about investing myself too deeply in the Standard Library are several posts were people report finding/fixing bugs in the library that do not seem to be incorporated by MetaQuotes, as well as an "eerie" feeling of distrust by a number of experienced members of the community, even in posts as recent as 2020 -- links to a few example below:

Based on the number of great contributions I saw in these forums from you , William, I would certainly appreciate your take on this... or anyone else for that matter. THE QUESTION IS --  why does it appear that very few developers choose to rely on the MQL5 Standard Library in their projects? -- this has me really puzzled :-)