Skip to content
All library documents

Asynchronous Parallel Calculations in an MQL5 Indicator

Article MQL5 code base

Summary

This programming demonstration shows how an MQL5 client can dispatch lengthy calculations to separate worker threads associated with chart objects. A helper header creates those objects and applies a worker expert adviser; after a task finishes, its chart object is removed. The example’s workload is a batch of square-root calculations, intended to illustrate the mechanism rather than trading analysis.

The indicator uses configurable thread and task counts, and starts work when the user clicks the chart. Its logs compare four tasks on two cores with execution on one core, illustrating the potential speed benefit of parallel work. The author cautions against requesting more threads than physical cores and notes that users must compile the worker first and implement their own data transfer between client and worker. The approach is presented for programmers, with scripts and services stated as unsupported; the demonstration does not establish general speed gains for other workloads.

Key ideas

  • The indicator delegates lengthy tasks to worker expert advisers running through chart objects.
  • A configurable number of tasks can be distributed across a chosen number of threads.
  • The demo compares execution logs for four tasks on one versus two cores.
  • Users must build their own data marshalling for other calculations, and the example is intended for programmers.

Tags

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