Testing & evaluation
Why an MT5 EA backtest is slow: a source-code checklist
Fast testing starts with identifying the expensive work. A non-visual run can still spend time on repeated calculations, log output and timer events even when no animated chart is shown.
Separate startup from steady-state work
Record history-download time, initialization time and the speed of a short repeatable interval. The first run may be waiting for data while later runs are doing actual simulation. Compare runs using the same compiled file, inputs, model and dates before attributing a speed change to code.
Inspect the repeated operations
Look for indicator handles created repeatedly, unnecessarily large history copies, scans of every past deal on every tick and verbose Print calls inside tight loops. Consider caching stable information and requesting only the data actually needed. Refresh cached values when their underlying environment can change.
Separate display work from trading decisions
A display panel can update on a suitable timer or only when its content changes. Chart redraws need not be coupled to every decision. However, do not move trailing stops, position protection or tick-sensitive entries behind a new-bar gate simply to make a test faster. That changes the strategy.
Prove the intended behaviour survived
- Keep a baseline run over a fixed interval.
- Change one measured bottleneck.
- Compare entries, exits, volumes and summary metrics.
- Inspect any differences before accepting the speed improvement.
- Repeat with a representative longer interval.
Make it yours with MQLume
This is where editable source becomes especially valuable. MQLume projects let you inspect the work inside the EA and build focused improvements. Explore The Gold Reaper MT5 as a starting project.