Skip to content
All library documents

Building an Expert Advisor Receiver for Chart Trade Messages

Article MQL5 articles

Summary

This article describes the receiving side of a communication protocol between a MetaTrader 5 Chart Trade indicator and an Expert Advisor. Since the indicator cannot submit or manage orders, it sends custom chart events containing serialized trade details; the Expert Advisor handles those events, splits the message into fields, checks the event type and symbol, and stores the parsed values. The example prints the decoded structure for demonstration rather than placing trades.

The article also discusses design choices in the receiver, including dynamically creating a decoder class and mapping delimited message fields into a structure. It warns that compact positional structure initialization can silently assign values incorrectly if the structure's field order changes. This is a programming tutorial about application communication and order-system architecture, not evidence for a trading strategy. The example protocol and checks are introductory and do not establish production-level validation or error handling.

Key ideas

  • In MetaTrader 5, the Expert Advisor receives trade instructions because indicators cannot execute orders.
  • Custom chart events can carry serialized instructions from a Chart Trade indicator to an Expert Advisor.
  • The receiver parses the delimited message and checks its event type and symbol before updating its state.
  • Compact positional structure initialization can become error-prone when the structure's field order changes.
  • The example demonstrates message decoding and printing, while actual order execution is left for later work.

Tags

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