Best practice to speed up backtesting

 

As my EA gets more robust it inevitably is taking longer to backtest.

What operations should I avoid to help speed up the bot, are there certain things I should/should not be doing.

I know that I will have to optimize my code somehow I just dont know where I should be looking.

Thanks

 
Don't do per tick what you can do per bar or per order.
          How to get backtesting faster ? - MT4 - MQL4 and MetaTrader 4 - MQL4 programming forum
 

Try to reduce the input parameters to optimize. Can some be calculated in init() based on symbol?

 

Here are some lessons learned:

  1. don't use the optimizer if your EA reads every tick
  2. use the open bar whenever possible. Most of the time, it's enough. If not, then go to lower timeframes. M1 opening time is far better than every tick. But then you need more history, that's another (tick) story... ;-)
  3. avoid using external indicator. If you ever do this, it is better to have the code in your EA directly
  4. don't look at anything on the chart, better to have everything in memory (array or simple variables)
  5. don't look back in the chart if you can. If your EA can stick to the current bar information, it's the fastest
I am sure I miss some others, but it can help you already, I am sure.

 
Sovattha Sok:

Here are some lessons learned:

  1. don't use the optimizer if your EA reads every tick
  2. use the open bar whenever possible. Most of the time, it's enough. If not, then go to lower timeframes. M1 opening time is far better than every tick. But then you need more history, that's another (tick) story... ;-)
  3. avoid using external indicator. If you ever do this, it is better to have the code in your EA directly
  4. don't look at anything on the chart, better to have everything in memory (array or simple variables)
  5. don't look back in the chart if you can. If your EA can stick to the current bar information, it's the fastest
I am sure I miss some others, but it can help you already, I am sure.

What do you mean by dont look at anything on the chart?

I am using an external indicator currently, is it easy to copy it into my EA, it seems somewhat complicated.

 
Nathan Hennigh:

What do you mean by dont look at anything on the chart?

I am using an external indicator currently, is it easy to copy it into my EA, it seems somewhat complicated.

I mean do not look at anything graphical like trend lines, lines of support or resistance or the like. It's the most inefficient.

Your external EA might be inefficient, so I found out that re-writing the code inside the EA helps also to have better performance. 
Reason: