Why is my backtest slow?

 

Hello


I'm curious to know why my backtesting has been slow ... ?

I'm on a 16GB Ram SSD with free spaces and the tester only takes less than 35% of the CPU yet the backtesting is slow MT5


Thought the EA has some drawings at specific times, not all-time drawings but it shouldnt be too slow as it is currently backtesting a single month for about 2h-3hours...Geez


Ideas on how to speed things up better?

 

load the EA once every bar.

If it depends on close of the bar , do not run on every tick.

If it depends on tick there is nothing you can do .

 
tec.nacks: Ideas on how to speed things up better?
  1. EAs : Don't do per tick what you can do per bar, or on open.
    If you are waiting for a level, don't reevaluate, wait until price reaches it (or a new bar starts, and you recalculate.)
    If you are waiting for an order to close, only look when OrdersTotal (or MT5 equivalent) has changed.
              How to get backtesting faster ? - MT4 - MQL4 programming forum (2017)

  2. Indicators: Code it properly so it only recomputes bar zero (after the initial run).
              How to do your lookbacks correctly. (2016)
              3 Methods of Indicators Acceleration by the Example of the Linear Regression - MQL5 Articles. (2011)
    Or, reduce Tools → Options (control+O) → Charts → Max bars in chart to something reasonable (like 1K.)

 

1 . Use less funtions such as PositionsGetxxx() , HistoryGetxxxx() , Symbolinfoxxx() , Try not to use or use only once as much as possible on per Ontick() or OnTime() 

2 . Optimization cycle in your EA .

 
tec.nacks:

Hello


I'm curious to know why my backtesting has been slow ... ?

I'm on a 16GB Ram SSD with free spaces and the tester only takes less than 35% of the CPU yet the backtesting is slow MT5


Thought the EA has some drawings at specific times, not all-time drawings but it shouldnt be too slow as it is currently backtesting a single month for about 2h-3hours...Geez


Ideas on how to speed things up better?

If you are running the same test again and again see if there is any gain by precalculating the static parts of your strategy vs calculating them always.Nowadays the case is usually that its faster to calculate but if you have complex calculations in indicators etc (with parameters that don't vary across tests) look into that.

Also your ArrayResize , if you call it with every new item you add to your arrays with the reserve parameter 0 it will slow you down if used massively . (when i want to speed things up the ,the first aspect i look into is memory management , almost always)

 

okay, thanks


I'll look into all

Reason: