MQL5: Programatically pause/unpause backtest, or slow down / increase speed


My MT5 EA is creating a file that will be read by an external system, and then that system creates a response file that my EA reads.

This process happens once per M1 bar and takes about 1-2 seconds, so when running live, timewise there is plenty of margin.

The problem occurs when running a backtest in Strategy Tester. The external system still needs 1-2 seconds, and even if I have a loop that checks for the return file, it will miss many candles, since with the higher backtest speed, many bars will pass while my EA is waiting for the response file for 1-2 seconds. I know I can slow down the backtest, but if I slow it down enough to know that no candles will be missed, it will take forever to run a test

So what I would like to do, programmatically, is to:

1. Pause the backtest, or change the speed to the lowest speed possible

2. Wait (with a loop) for the response file and read it 

3. Unpause the test, or change the speed to the highest spied possible

I have tested pausing with the space key command, but that seems to be far too slow.

I have tested using DebugBreak, but I don't know of any way to programmatically Resume the test.

If someone has the solution to this, it would be very appreciated.


you can "sendKey" to pause and later on send un-pause (resume) key with delay/sleep() to slow down backtest.

Good luck