Skip to content
All library documents

Exporting Multi-Core MQL5 Optimization Results and Custom Metrics to CSV

Article MQL5 articles

Summary

This article presents an MQL5 framework for consolidating Strategy Tester optimization results in CSV files, including custom measures that native tester statistics do not provide. It describes calculating Sortino ratio from losing deals, average holding duration by matching opening and closing deals, and filter behavior measures such as lag, rapid reversals, price distance from the filter, and crossing frequency. A demo trend-pullback Expert Advisor compares several moving-average filters and records these measures alongside standard performance statistics.

The central implementation problem is concurrent agents attempting to append results to one file. Since the article says Sleep is ineffective during optimization, its export engine repeatedly tries to open the shared file in a bounded spin loop, logs an error if retries fail, then appends the row. The article explains the design and supplies implementation examples, but reports no empirical validation of data-loss rates or timing under different workloads. The exported metrics support later comparison; the framework does not prescribe how to interpret them, and the author notes that thresholds depend on instrument, timeframe, and risk context.

Key ideas

  • Custom performance and signal-quality metrics can supplement native Strategy Tester statistics.
  • Average trade duration can be estimated by matching opening and closing deals by position identifier.
  • Concurrent optimization agents can contend for a shared CSV file and lose output when file opening fails.
  • A bounded retry loop is proposed to acquire the file without relying on Sleep during optimization.
  • The framework exports data for analysis but does not determine which filter or metric is best.

Tags

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