Discussion of article "Library for easy and quick development of MetaTrader programs (part IX): Compatibility with MQL4 - Preparing data"

 

New article Library for easy and quick development of MetaTrader programs (part IX): Compatibility with MQL4 - Preparing data has been published:

In the previous articles, we started creating a large cross-platform library simplifying the development of programs for MetaTrader 5 and MetaTrader 4 platforms. In the eighth part, we implemented the class for tracking order and position modification events. Here, we will improve the library by making it fully compatible with MQL4.

Improving the library

In the DoEasy library root folder, create the new ToMQL4.mqh include file. Here we will describe all necessary constants and enumerations for MQL4. Include it to the Defines.mqh file for MQL4 compilation at the very beginning of the Defines.mqh listing:

//+------------------------------------------------------------------+
//|                                                      Defines.mqh |
//|                        Copyright 2018, MetaQuotes Software Corp. |
//|                             https://mql5.com/en/users/artmedia70 |
//+------------------------------------------------------------------+
#property copyright "Copyright 2018, MetaQuotes Software Corp."
#property link      "https://mql5.com/en/users/artmedia70"
//+------------------------------------------------------------------+
//| Include files                                                    |
//+------------------------------------------------------------------+
#ifdef __MQL4__      
#include "ToMQL4.mqh"
#endif               
//+------------------------------------------------------------------+

After that, the entire MQL4 library will be able to see what is written in the ToMQL4.mqh file during compilation.

Let's move to the very beginning of the error list in the Errors tab of the Editor's Toolbox by pressing NumPad Home or by simply scrolling up to the very start. Double-click the very first error:

Author: Artyom Trishkin

 

Good afternoon. I like your trial Expert Advisor. I want to try to use it as a kernel, which will receive signals and filters from various indicators, their combinations, or controlled manually, through button presses.

You have already seen the first of such Expert Advisors and helped me to breathe life into it on a neighbouring thread of this forum.

Can you show me in this trial EA of yours how to press buttons programmatically?

Is there a suitable function - can you share it?

Or suggest how best to do it, please.

 
Sergey Voytsekhovsky:

Good afternoon. I like your trial Expert Advisor. I want to try to use it as a kernel, which will receive signals and filters from various indicators, their combinations, or controlled manually, through button presses.

You have already seen the first of such Expert Advisors and helped me to breathe life into it on a neighbouring thread of this forum.

Can you show me how to press the buttons programmatically in this trial EA of yours?

Is there a suitable function - can you share it?

Or suggest how best to do it, please.

The Expert Advisor presented in the articles is just a test EA. It is not suitable for use for trading on accounts. Buttons created in this Expert Advisor are also just a set of ordinary objects for quick testing of new library functionality added in each subsequent article. In the future, when creating the graphical shell of the library, these simple buttons will be replaced by buttons created using the graphical functionality of the library.

And what do you need "software button pressing" for, if it is a regular call of trade functions? Why call a trade function via a software button press when you can call the trade function from the programme immediately? This will be a "software button press".

 
Artyom Trishkin:

The Expert Advisor presented in the articles is only a test Expert Advisor. It is not suitable for use for trading on accounts. Buttons created in this Expert Advisor are also just a set of ordinary objects for quick testing of new library functionality added in each subsequent article. In the future, when creating the graphical shell of the library, these simple buttons will be replaced by buttons created using the graphical functionality of the library.

And what do you need "software button pressing" for, if it is a regular call of trade functions? Why call a trade function via a software button press when you can call the trade function from the programme immediately? This will be a "software click" on the button.

The point is that everything is already linked there, trade functions, classes, data. You don't need to bother with this side of the issue, you just need to press the button. And I am catastrophically short of experience and time to get it.

Using such a kernel, you can devote more time to algorithms of making trading decisions rather than to the mechanics of execution. Of course, the execution of decisions is also important, but it can be postponed a bit.

That's how I got my head around it.

 
Sergey Voytsekhovsky:

The point is that you have everything already linked there, trade functions, classes, data. You don't have to worry about this side of the issue, you just have to click a button. And I am cathostrophically short of experience and time to get it.

Using such a kernel, you can devote more time to algorithms of making trading decisions rather than to the mechanics of execution. Of course, the execution of decisions is also important, but it can be postponed a bit.

That's how I've done it.

Gradually, so much functionality will be added to the library that it will be very easy to work on algorithms in the way you want. And this is exactly the purpose for which it was conceived.

Now, while there is no such functionality there, you can see how the test Expert Advisor works with the CTrade trading class included in the standard library in MQL5, and write similar constructs to call the necessary trading functions. There is also a call of tester trading functions for MQL4 there (in the test EA).

Документация по MQL5: Стандартная библиотека
Документация по MQL5: Стандартная библиотека
  • www.mql5.com
Стандартная библиотека MQL5 написана на языке MQL5 и предназначена для облегчения написания программ (индикаторов, скриптов, экспертов) конечным пользователям. Библиотека обеспечивает удобный доступ к большинству внутренних функций MQL5.
 
Artyom Trishkin:

Gradually, so much functionality will be added to the library that it will be very easy to work on algorithms - the way you want. And this is exactly what it was designed for.

Now, while there is no such functionality there, you can see how the test Expert Advisor works with the CTrade trading class included in the standard library in MQL5, and write similar constructs to call the necessary trading functions. There (in the test EA) there is a call of tester trading functions for MQL4.

Thank you, I will study it.

 
Sergey Voytsekhovsky:

Good afternoon. I like your trial Expert Advisor. I want to try to use it as a kernel, which will receive signals and filters from various indicators, their combinations, or controlled manually, through button presses.

You have already seen the first of such Expert Advisors and helped me to breathe life into it on a neighbouring thread of this forum.

Can you show me how to press the buttons programmatically in this trial EA of yours?

Is there a suitable function - can you share it?

Or suggest how best to do it, please.

Good afternoon!

Sergey, I will support you because I see you are in a similar situation.

Yes, the articles are great, but they contain very little information about how to use the written code. Libraries, generally speaking, are valuable for hiding the implementation and providing a clear interface for practical tasks. The help of the https://docs.mql4.com/strings/stringsubstr function doesn't contain a single word about its internals. A description of incoming parameters, the result of their processing and example(s). This is what I would like to see.

Yes, Artem, you are undoubtedly a talented programmer, but application engineers need to develop another algorithm as quickly as possible and not spend hours over hundreds of lines of other people's code in search of enlightenment. The series of articles so far is more theoretical.

This is not my first post on this topic ). In no way I want to belittle the merits of the series. On the contrary - I hope, Artem, you will take into account the requests of the forum members and the written libraries will be used in EAs as eagerly as good films are quoted.

StringSubstr - String Functions - MQL4 Reference
StringSubstr - String Functions - MQL4 Reference
  • docs.mql4.com
StringSubstr - String Functions - MQL4 Reference
 
Nikolai Karetnikov:

Good afternoon!

Sergey, I support you, because I see you are in a similar situation.

Yes, the articles are great, but they contain very little information about how to use the written code. Libraries, generally speaking, are valuable for hiding the implementation and providing a clear interface for practical tasks. The help of the https://docs.mql4.com/strings/stringsubstr function doesn't contain a single word about its internals. A description of incoming parameters, the result of their processing and example(s). This is what I would like to see.

Yes, Artem, you are undoubtedly a talented programmer, but application engineers need to solve practical tasks rather than spend hours over hundreds of lines of other people's code in search of enlightenment. The series of articles so far is more theoretical.

This is not my first post on this topic ). In no way I want to belittle the merits of the series. On the contrary - I hope, Artem, you will take into account the requests of the forum members and the written libraries will be used in EAs as eagerly as good films are quoted.

The goal is to guide the reader from the beginning of the library creation to its completion.
You see - the articles are more educational in nature, while having a useful practical purpose, and more than one. The design of the codes is easy to understand, without using twists and undocumented features for the sake of twists and "coolness". But there is an undeniable plus - how many beta versions of the terminal have been released, and how many people have already said that their codes stopped working, and the library - lives from build to build without forced fixes because something suddenly stopped working....

The library currently has one entry point - the CEngine class (there will be a second entry point, but much later), and the object of this class in the EA gives full access to all the features.

And further - it is not difficult to create such an object, for example: CEngine lib; and in the code type lib and put a dot (like this: lib.) - after the dot the editor will show you a window with a list of all available for use methods of the library. Most of them have meaningful names - with a little practice you can use them. All methods are described in articles. In each article there is an example of a test programme showing, however, a small part of the possibilities.

I agree - searching for the shown methods and their application in numerous articles without reference material is a difficult task.... But the cycle of articles is a cycle so that the reader goes through it together with me, and then something will be stored in his head :) And the purpose, I remind you, is educational.

There will be reference material. But at the very end - when the library will be created. And examples, of course, too.

In the meantime, you can ask practical questions. Show a part of your code and I will give you a hint. I'm here and I'm not going anywhere - it's not in my rules to abandon what I've started.

 
Artyom Trishkin:

The goal is to take the reader from the beginning of the library to its completion.
You see - the articles are more educational in nature, while having a useful practical purpose, and more than one. The design of the codes is easy to understand, without using twists and undocumented features for the sake of twists and "coolness". But there is an undeniable plus - how many beta versions of the terminal have been released, and how many people have already said that their codes stopped working, and the library - lives from build to build without forced corrections because something suddenly stopped working....

The library currently has one entry point - the CEngine class (there will be a second entry point, but much later), and the object of this class in the EA gives full access to all features.

And further - it is not difficult to create such an object, for example: CEngine lib; and in the code type lib and put a dot (like this: lib.) - after the dot the editor will show you a window with a list of all available for use methods of the library. Most of them have meaningful names - with a little practice you can use them. All methods are described in articles. Each article contains an example of a test programme, which shows only a small part of the possibilities.

I agree - searching for the shown methods and their application in numerous articles without reference material is a difficult task.... But the cycle of articles is a cycle so that the reader goes through it together with me, and then something will be stored in his head :) And the purpose, I remind you, is educational.

There will be reference material. But at the very end - when the library will be created. And examples, of course, too.

In the meantime, you can ask practical questions. Show a part of your code and I will give you a hint. I'm here and I'm not going anywhere - it's not in my rules to abandon what I've started.

I understand your intentions are the best and you probably have a lot of free time ).

I just saw your articles of the series "MakingSimple"[ Library for easy and fast creation of programmes for MetaTrader] and thought that after 10-15 minutes of reading I would be able to use useful code. I expected to see a classic article likehttps://www.mql5.com/en/articles/272, where the logic is hidden and the interface is open, where the questions are answered: "why it is needed", "how to work with it" and examples. Turns out the goal is training, not RAD (rapid development).

Well, we look forward to seeing you write one of these! ))

Трассировка, отладка и структурный анализ кода
Трассировка, отладка и структурный анализ кода
  • www.mql5.com
В данной статье речь пойдет про один из способов создания стека вызовов на этапе выполнения. Возможности, которые описаны в статье следующие: Составление структуры используемых классов, функций, файлов. Создание стека вызова, с сохранением всех прошлых стеков. Их последовательности вызовов. Просматривать состояние Watch-параметров на этапе...
 
Nikolai Karetnikov:

I realise your intentions are the best and you probably have a lot of free time )

I just saw your articles of the series "MakingSimple"[ Library for easy and fast creation of programmes for MetaTrader], I thought that after 10-15 minutes of reading I would be able to use useful code. I expected to see a classic article likehttps://www.mql5.com/en/articles/272, where the logic is hidden and the interface is open, where the questions are answered: "why it is needed", "how to work with it" and examples. It turned out that the goal was training, not RAD (rapid development).

Well, we look forward to seeing you write one of these! ))

Thegoal is learning + rapid development. About rapid development it's only worth asking practical application questions if you're too lazy to read and there's no reference material with examples yet.

The title rather translates as "Make it easy". (English..., allows to translate any way you want, if there is no context).