Discussion of article "Parallel Calculations in MetaTrader 5"

 

New article Parallel Calculations in MetaTrader 5 is published:

Time has been a great value throughout the history of mankind, and we strive not to waste it unnecessarily. This article will tell you how to accelerate the work of your Expert Advisor if your computer has a multi-core processor. Moreover, the implementation of the proposed method does not require the knowledge of any other languages besides MQL5.

Figure 1. Parallel execution of applications

Author: Andrew

 

Thanks to the author, relevant article. I've been pondering this topic as well, but didn't get to the article.

The author cautions that you should carefully monitor which instruments are running what. In the light of writing Expert Advisors that can be run on any pair, this is a bit difficult. You will have to keep track of which pair the EA is running on and adjust the pairs of parallel streams.

In this regard, a question (not so much to the author, but more to the MQ developers): is it possible to introduce custom tools?

In this way we could solve many tasks, starting from creating empty charts for parallelised calculations and finishing with creating tick charts of our own making.

As for the data transfer buffer, I can advise you to create a global structure and transfer different types of data by the structure. I know from experience that it is not always convenient to return the result of calculations in the form of an array, often you have to track some counters, and not to confuse the names it is easier to pass everything as a structure and already refer to variables as members of the structure. By the way, the same structure can include arrays.
Документация по MQL5: Основы языка / Типы данных / Структуры и классы
Документация по MQL5: Основы языка / Типы данных / Структуры и классы
  • www.mql5.com
Основы языка / Типы данных / Структуры и классы - Документация по MQL5
 
Urain:

In this regard, a question (not so much to the author, but more to the MQ developers): is it possible to introduce custom tools?

Hmm, I like the idea.
 

Perhaps I will repeat the idea already expressed here about custom tools, but I would like to add....

Now an Expert Advisor (indicator, script) is launched only on a specific symbol. It has access to the current data of other symbols, but the OnTick event is generated only for the host symbol, on whose chart the Expert Advisor is launched.

Perhaps it would be logical to introduce the possibility to create your own"custom tool", which is like an add-on. which is like a superstructure over Expert Advisors and has the ability to receive and process ticks from several symbols, passing the results to programmes (parts of the programme or Expert Advisors, indicators) working with a specific symbol in their own thread. This greatly facilitated and spurred the creation of "multicurrency". And the very concept of object programming pushes to it. Why bind an Expert Advisor to a particular symbol if you work with several symbols?

P.S.Well, or it would be good to add to the SymbolInf... functions something like the event "a new tick for this symbol has arrived".

 
lav888:

Now the Expert Advisor (indicator, script) is launched only on a specific symbol. It has access to the current data of other symbols, but the OnTick event is generated only for the host symbol, on whose chart the Expert Advisor is launched.

It is hard to understand why the developers repeated the crutch. After all, when the MQL5 architecture was being developed, there already existed a very strong API, in which onTick triggered for any tick of any signed symbol.

In general, I don't understand why they chose such an architecture and took so little from the already existing API, which was very competent in terms of architecture.

MQL5 developers behave as if they are reinventing the wheel: "we will think about this feature", "yes, you are right, we will add it", etc.

It has been mentioned several times that more than one year was spent on working out the architecture. So there are some arguments why they decided to do it this way and not otherwise.

P.S. Perhaps the reason lies in the fact that MetaTrader developers have little experience in brokerage and trading, but a huge experience in writing platforms. Other developers, on the contrary, had huge experience in real brokerage and market trading.

P.P.S. I wrote my thoughts, not speculations. It is always easier to criticise than to create. Developers, despite obvious blunders, deserve Respect.

 
lav888:

Perhaps it would be logical to introduce the possibility to create your own"custom tool" , which is like an add-on over Expert Advisors and has the ability to receive and process ticks from several symbols, passing the results to programmes (parts of the program or Expert Advisors, indicators working with a specific symbol) which is like a superstructure over EAs and has the ability to receive and process ticks from several symbols, passing the results to programmes (parts of the programme or EAs, indicators) working with a particular symbol in their own thread. This greatly facilitated and spurred the creation of "multicurrency". And the very concept of object programming pushes to it. Why bind an Expert Advisor to a particular symbol if you work with several symbols?

P.S.Well, or it would be good to add to the SymbolInf... functions something like the event "a new tick for this symbol has arrived".

Such an "add-on" can be implemented using standard MQL5 tools: Multicurrency tick handler OnTickMarketWatch
 
Lizar:
This "add-on" can be implemented using MQL5 standard tools: Multicurrency tick handler OnTickMarketWatch

Thank you. It was this article that pushed me to the above conclusions. But as you yourself noticed in this article:

Tips for use:

1. This variant of the multicurrency tick handler is quite resource intensive. You can ease the load on the processor by increasing the delay of the time of receiving ticks in the script, using the delay variable. But at the same time you can skip some number of ticks.


If you increase the delay time up to 1 second, you can get the same effect using OnTimer(). Unfortunately with the same disadvantages.

At the same time, the terminal continuously receives and processes ticks by symbols from the "Market Window". We have access to these ticks, but we have no signal that these data have been updated. That is why we have to do the check artificially. The advantage of MQL5 is that it can be done. But agree that it would be much more elegant to have a solution embedded in the terminal functions. Let it be a separate event like OnTrade() and the developer can use it at his discretion (or not).

And about "custom tools" or superstructure over experts.... I realise that this is a kind of "dreaming" and should have been thought of at the design stage... It's a pity!

 
lav888:

Thank you. It was this article that pushed me to the above conclusions. But as you yourself have pointed out in this article:

Tips for use:

1. This variant of the multi-currency tick handler is quite resource intensive. You can ease the load on the processor by increasing the delay of the time of receiving ticks in the script, using the delay variable. But at the same time you can skip some number of ticks.


If you increase the delay time up to 1 second, you can get the same effect using OnTimer(). Unfortunately with the same disadvantages.

At the same time, the terminal continuously receives and processes ticks by symbols from the "Market Window". We have access to these ticks, but we have no signal that these data have been updated. That is why we have to do the check artificially. The advantage of MQL5 is that it can be done. But agree that it would be much more elegant to have a solution embedded in the terminal functions. Let it be a separate event like OnTrade() and the developer can use it at his discretion (or not).

And about "custom tools" or superstructure over experts.... I realise that this is just a "dream" and should have been thought of at the design stage...It's a pity!

Yes, in general I agree. And as for dreaming, everything we have now was once someone's dream. If there are strong arguments, then"user tools" will appear.
 

Okay! Now it remains for the developers to hear us. It would be good if this add-on could include thread management functions at once.

It would be possible to run each processing in its own thread. Perhaps it would allow processing a new tick while working with the current tick.

 

Useful article. It opened new horizons.

I have a question: can the OnTick() function be turned into a function with a parameter, like OnTick(EURUSD), so that ticks from different instruments could be processed in parallel in one Expert Advisor? Of course, with processing of each instance of a single-parameter function in a separate thread (on a separate kernel).

Документация по MQL5: Основы языка / Функции / Функции обработки событий
Документация по MQL5: Основы языка / Функции / Функции обработки событий
  • www.mql5.com
Основы языка / Функции / Функции обработки событий - Документация по MQL5
 
Great article. Thanks for sharing.