MQL5 Services for Background Tasks and Synthetic Price Feeds
Summary
The article explains how MQL5 services run independently of charts and how to manage them in MetaTrader 5. A service starts through its OnStart handler; it can perform a one-time task and exit or remain active in a loop until stopped. The examples show service startup and shutdown logging, a wait loop, and the use of multiple instances with separate input parameters. Services run in their own threads, but they cannot use timer functions or indicator-buffer operations.
The later example describes a service that builds a custom DXY symbol from component currency-pair prices, adding calculated index ticks and restricting updates by day of week to avoid weekend data. The article outlines a practical route to ongoing data handling and custom price-feed creation. It is an implementation guide rather than a trading strategy: it provides no performance testing, and the author cautions that services can interact with other terminal programs, so developers must manage those interactions.
Key ideas
- MQL5 services run independently of charts and begin execution through an OnStart handler.
- A service can exit after a one-time task or loop until the user stops it.
- Each service runs in its own thread, and several instances can use different input parameters.
- Services can process external data and update custom symbols, such as a synthetic currency index.
- The examples do not evaluate trading performance, and service interactions with other terminal programs require care.
Tags
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.