How an MQL5 Service Coordinates Replay Indicators and Chart State
Summary
This article explains a small MetaTrader 5 service used to clarify how a replay system's service, control indicator, and mouse indicator interact. The service creates a custom symbol, supplies it with a sample bar, opens a chart, attaches the indicators, and repeatedly reads a control buffer. It then packs position and mode state into a value and sends a custom chart event, allowing the service and indicator to exchange state while the service remains active.
The discussion covers why a service differs from a chart-bound script, how an indicator can be embedded as a compiled resource, and how a loop checks for shutdown and chart availability. The service is presented as a simplified learning example whose interaction model can inform a larger replay or simulator implementation. It does not demonstrate a trading strategy, market replay accuracy, or performance results; its value is mainly in explaining MQL5 program structure and synchronization behavior.
Key ideas
- An MQL5 service can run independently of a chart and maintain a loop after its start event.
- The example creates a custom symbol and chart to host two indicators.
- The service reads indicator buffer data and sends state through custom chart events.
- Embedding a control indicator as a resource simplifies deployment while leaving the mouse module accessible.
- The example teaches program interaction patterns rather than trading performance.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.