Discussion of article "MQL5 for beginners: Anti-vandal protection of graphic objects"

 

New article MQL5 for beginners: Anti-vandal protection of graphic objects has been published:

What should your program do, if graphic control panels have been removed or modified by someone else? In this article we will show you how not to have "ownerless" objects on the chart, and how not to lose control over them in cases of renaming or deleting programmatically created objects after the application is deleted.

One of the advantages of the MQL5 programming language is that with the existing MQL5 standard functions you can form codes for completing various tasks and achieving different goals when using the MetaTrader 5 trading terminal.

This article, written in a simple language and containing easy examples, considers two variants of implementing program's response actions to the control panel's graphic objects being deleted or changed. We are going to reveal how you can ensure that after the program is deleted, there are no ownerless objects present on the chart, over which the program may have lost control, because somebody or something has renamed them.

Example of a control panel before and after its objects' properties have been manually changed

Fig. 1. Example of a control panel's appearance before and after its object's properties have been manually changed

Options for constructing the response actions to external interference in the code, described in this article, may not be redundant for those cases where, for example, a third-party program launched on the chart and not directly intended for its cleanup, uses a function for deleting objects (ObjectsDeleteAll () or the one you create yourself), operating by the parameters set in it:

  • complete removal of all types of graphic objects in the same window/subwindow with objects created manually or using other programs;
  • or complete removal of the type of objects that are also present in your program's control panel;
  • or removal by prefix that matches the prefix of your program's objects.

These options are also relevant, when it is advisable, including for the program's correct operation, to provide actions for accidental or intentional removal of its control panel's objects or manual change of their properties in the code.

This article can also be helpful for those who just started learning the event handling in the OnChartEvent() function.

Author: Dina Paches

 

This article is totally obsolete.

1. It´s definitely not for beginners

2. It´s not MQL5 - it is MQL4!

3. The way of coding is totally complicated and - in view of MQL5 - totally wrong anyway.

 

If one thinks it´s a problem, that another EA or indicator could destroy objects, this can be done much more efficient and elegant:

- Define an MQL object for each chart object, such as the standard Control library already does. Each such MQL object represents a chart object and holds all it´s data - normal MQL5 style.

- Pack all the objects into a master container

- Only the master container checks, if a chart object has been deleted, either from time to time or by the corresponding chart-event during OnChartEvent(). 

- Add a .ReCreate() member function to CWnd, and an OnRecreate() virtual function to all objects which implement this functionality 

- If the master container detects kind of "vandalism", it sends a .ReCreate() to all it´s child objects

Done.

 

I've got little understanding of English. I didn't read the version of this article in English.

Sorry, but... did you read this article in its entirety?

Do you speak Russian?

If you speak Russian, then you and I can talk more constructively at the discussion at the Russian version of this article.


Doerk Hilger:

This article is totally obsolete.

You are wrong.

Doerk Hilger:

1. It´s definitely not for beginners

Why do you think so? Tell me this, please, in more details.

Doerk Hilger:

2. It´s not MQL5 - it is MQL4!

You are wrong.

But the schemes described in this article can be used not only for MQL5, but and for MQL4.

Doerk Hilger:

3. The way of coding is totally complicated and - in view of MQL5 - totally wrong anyway.

Пожалуйста прочитайте эту статью "MQL5 для начинающих: Антивандальная защита графических объектов" ещё раз внимательно. И пожалуйста не торопитесь с выводами. Если и после этого ваше мнение не изменится, то напишите более конкретно непонятные для вас моменты.

Please read this article "MQL5 for beginners: Anti-vandal protection of graphic objects" again carefully. And please do not rush to conclusions. If after this will not change your opinion, write more particularly difficult moments for you.


Doerk Hilger:

If one thinks it´s a problem, that another EA or indicator could destroy objects, this can be done much more efficient and elegant:

- Define an MQL object for each chart object, such as the standard Control library already does. Each such MQL object represents a chart object and holds all it´s data - normal MQL5 style.

- Pack all the objects into a master container

- Only the master container checks, if a chart object has been deleted, either from time to time or by the corresponding chart-event during OnChartEvent(). 

- Add a .ReCreate() member function to CWnd, and an OnRecreate() virtual function to all objects which implement this functionality 

- If the master container detects kind of "vandalism", it sends a .ReCreate() to all it´s child objects

Done.

В статье "MQL5 для начинающих: Антивандальная защита графических объектов" рассматриваются схемы только двух вариантов (способов) из множества возможных. Но различных вариантов (способов) конечно может быть много.
Применять или не применять схемы из этой статьи - это зависит только от ваших решений.


Скажу только, что эти две схемы из статьи "MQL5 для начинающих: Антивандальная защита графических объектов" обладают следующими положительными качествами:

  • экономно используют ресурсы компьютера и торгового терминала;
  • имеют высокий уровень своевременности срабатывания (не все другие обычные привычные способы могут быть своевременными);
  • могут быть применены совместно со многими другими вариантами (способами).

Эти схемы из данной статьи сконструированы в процедурном стиле. В том числе, чтобы они были более понятны, наглядны и могли послужить идеями для каких-то других вариантов.

Если вам не нравятся эти схемы или они не подходят вам по каким-то другим причинам, вы конечно можете использовать другие схемы. И, естественно, в том стиле программирования, что для вас привычен.

Применять эти схемы из статьи или не применять - это ваше личное дело и право.


In the article "MQL5 for beginners: Anti-vandal protection of graphic objects" are considered only two options schemes (methods) of many possible. But the options (methods) can be a lot.
To use or not to use the schemes from this article - it just depends your decisions.

I can only say that these two schemes from the article "MQL5 for beginners: Anti-vandal protection of graphic objects" have the following positive qualities:
  • economical use resources of the computer and the trading terminal;
  • have a high level of timeliness of response (not all the other usual habitual ways can be timely);
  • they may be used in conjunction with many other ways.

These schemes this article were made in a procedural style. In particular, to make them more understandable, visible and could serve as ideas for some other options.

If you do not like these schemes or they do not fit you for some other reason, you can of course use other schemes. And, of course, in the style of programming that you like.

To use or not to use the schemes from this article - it depends your decisions.


Sorry for my English.


P./S.: Пожалуйста прочитайте эту статью ещё раз внимательно. И пожалуйста не торопитесь с выводами. Если у вас затем будут конструктивные вопросы или предложения, то пишите, пожалуйста. Я смогу ответить вам скорее всего только после новогодних каникул. Это через пять дней.

Please read this article again carefully. And please do not rush to conclusions. If you will have any specific questions and suggestions, please write. I can answer you will probably only after the New Year holidays. It is in five days.

P./S.: Сегодня у нас праздник Нового года. Поэтому и вас поздравляю с наступающим новым 2016-м годом!

Today we have the New Year holiday. Therefore you Happy New 2016 Year!

 
Dina Paches:

I've got little understanding of English. I didn't read the version of this article in English.

Sorry, but... did you read this article in its entirety?


+1

Very good answer.

 
Doerk Hilger:

- Define an MQL object for each chart object, such as the standard Control library already does. Each such MQL object represents a chart object and holds all it´s data - normal MQL5 style.

- Pack all the objects into a master container

- Only the master container checks, if a chart object has been deleted, either from time to time or by the corresponding chart-event during OnChartEvent(). 

- Add a .ReCreate() member function to CWnd, and an OnRecreate() virtual function to all objects which implement this functionality 

- If the master container detects kind of "vandalism", it sends a .ReCreate() to all it´s child objects

This article offers an sample of ready-made solution for implementing in any source code - OOP or procedural. So, the task is: find a tie to match the suit

Your solution: buy a new OOP-suit. Oh, and also don't forget to buy a tie for your new suit

PS As for Standard Library: unfortunately Control library is the worst part of this library - too many bugs & unrealised or unaccessible options. As result - sometimes this library is a source of problems (garbage on chart), referred in this article

Reason: