MT5 ↔ Python ↔ EA ↔ CMA-ES Communication Issue

 

Hello everyone,

I'm working on an MT5 Expert Advisor that is controlled by an external Python CMA-ES optimizer.

Current workflow:

                                                    Python (CMA-ES)

Generate candidate.set

Start MT5 Strategy Tester (tester.ini)

EA loads inputs from candidate.set

EA writes results to CMA_RESULT.csv

Python reads CMA_RESULT.csv and continues optimization

Problem

  • Python generates different candidate.set files correctly (parameter values are changing).
  • MT5 starts a new backtest for each candidate.
  • CMA_RESULT.csv is found and successfully read by Python.
  • However, Python receives almost identical results for every candidate:

                                                    Profit ≈ -64
PF ≈ 0.9859
Trades ≈ 2875
DD ≈ 5.82%

This makes it look like one of the following is happening:

  1. MT5 is not actually loading the new .set files.
  2. The EA is not applying the changed input parameters.
  3. Python is repeatedly reading the same CMA_RESULT.csv data.
  4. MT5 is using cached tester settings instead of the candidate-specific settings.

Additional Information

  • The generated candidate.set files definitely contain different parameter values.
  • Python detects updated timestamps on CMA_RESULT.csv .
  • MT5 is launched via:

                                                    terminal64.exe /config:tester.ini

  • The EA writes results to:

                                                    C:\Users\...\AppData\Roaming\MetaQuotes\Terminal\Common\Files\CMA_RESULT.csv

  • I have already verified that Python can read the file successfully.

Question

Has anyone built a reliable MT5 + Python + CMA-ES optimization workflow before?

What are the most common reasons why different .set files result in almost identical backtest outputs, even though the parameter values are changing?

Any suggestions or debugging ideas would be greatly appreciated.

Thank you! 🚀