Skip to content
All library documents

Scheduling Repeated Tasks in MQL5 with a Python-Inspired Module

Article MQL5 articles

Summary

The article describes an MQL5 scheduling class modeled on Python’s Schedule module. It explains how a fluent interface combines an interval and unit, then associates the schedule with a function. Jobs are stored with their interval and previous and next run times, while a recurring timer event checks which jobs are due. The examples cover intervals from seconds through years and discuss more specific scheduling features, such as running tasks at particular times, passing arguments, time zones, and managing jobs.

The practical motivation is that MQL5’s single OnTimer interval can be too rigid when an Expert Advisor needs several tasks on different schedules, such as producing periodic trading reports. The article contrasts the proposed scheduler with calling checks on every market tick and recommends using OnTimer to run pending jobs. It presents implementation details and sample applications, but gives no benchmark or evidence about timing accuracy under load. The article is a programming guide, not a trading strategy, and the provided scheduling approach should be evaluated in the context of the application’s timing and platform constraints.

Key ideas

  • A scheduler can manage multiple recurring tasks with different intervals in one MQL5 program.
  • The class uses a fluent interface to set an interval and unit before registering a function.
  • A shared job list stores each function together with its timing state.
  • A timer event can check pending jobs without tying task execution to market ticks.
  • The article describes scheduling utilities but does not test their accuracy or trading performance.

Tags

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