New article - MQL5 Cookbook: Handling Typical Chart Events

 

New article MQL5 Cookbook: Handling Typical Chart Events has been published:

In my article I would like to describe the capabilities and hands-on practice of using OnChartEvent() with typical (standard) events predefined by MQL5 developers. The MQL5 articles and Code Base already contain examples of using this handler.

However, my purpose is to analyze this instrument in the context of Event-Oriented Programming (EOP). I believe that this handler can be successfully used for fully automatic and semi-automatic trading systems.


1. "ChartEvent" Event

So, first let's see what this type of event is.

According to the Documentation, the ChartEvent event may appear when working with a chart, in particular when:

  • pressing a key on the keyboard when a chart window is in focus.
  • creating a graphical object.
  • deleting a graphical object.
  • clicking on a graphical object.
  • dragging a graphical object with a mouse.
  • finishing to edit text in a text field of a LabelEdit graphical object.

Thus, this event brings interactivity and allows interacting with a chart. Moreover, such an interaction may be a result of manual trading, as well as of some algorithmic operations (automated trading).

MQL5 developers classify the ChartEvent event by types specified in the ENUM_CHART_EVENT enumeration.

It is important to note that this list has a range of user-defined events, that act as a hidden reserve to serve the programmer. MQL5 developers provide 65535 IDs for custom events.

To work with custom events, a special generator function EventChartCustom() is available for programmer's needs. However, this article does not consider custom events.


Author: Dennis Kirichenko

Reason: