Skip to content
All library documents

Reducing Expert Advisor Runtime by Updating Data on New Bars

Article MQL5 code base

Summary

The document describes a code-level optimization for an MQL5 Expert Advisor that runs on every tick. Its main idea is to retrieve indicator and time-series data only when a new bar appears, while retaining variables between calls using static storage. This avoids repeating work on every tick when the underlying bar data has not changed.

It reports three EURUSD one-minute strategy-tester runs before and three after the change, with the same stated tick and bar counts. The post-change runs finish faster, and the author characterizes the saving as about two minutes. These timings are implementation benchmarks, not evidence that trading performance or risk improved. The report notes that the terminal was restarted before each run but caches were not cleared, so cache state may affect comparisons; it also gives no broader tests across instruments, platforms, or workloads.

Key ideas

  • The Expert Advisor runs on each incoming tick.\nIndicator and time-series data can be fetched only when a new bar appears.\nStatic variables preserve values between calls and can reduce repeated calculations.\nThe reported tester timings are runtime evidence, not evidence of better trading returns.\nUncleared caches and a single stated instrument and timeframe limit the benchmark.

Tags

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