Skip to content
All library documents

MQL5 Custom Events and Message Routing Between Chart Programs

Article MQL5 articles

Summary

The article explains how MQL5 programs communicate through chart events. It describes the OnChartEvent handler, class-level message dispatch, and EventChartCustom, which lets a program send a custom message that the chart’s event handler can process. The example uses a control indicator to initialize values in a class through a custom event.

The main concern is event collisions: custom event identifiers can overlap across indicators and Expert Advisors attached to the same chart. An event intended for one component may therefore be handled by another, potentially causing confusing behavior or platform problems. The article recommends understanding how programs interact when combined and suggests experimenting with custom events across programs and charts. It introduces the issue but defers the solution to later articles; it provides no trading strategy or empirical performance evidence.

Key ideas

  • MQL5 routes chart and custom events through the OnChartEvent handler.
  • A class can centralize message handling through a dispatcher such as DispatchMessage.
  • EventChartCustom allows a program to send custom events to the chart handler.
  • Custom event identifiers may conflict when multiple programs share a chart.
  • The article identifies event collisions as a risk but postpones its solution.

Tags

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.