Low EA speed in backtest

 

Hello everyone, I have written an EA. The speed of EA in the backtest is good at first, but after a while, the speed decreases drastically. How should I solve this problem? Thank you for your guidance

 
Alireza Saadatinia: Hello everyone, I have written an EA. The speed of EA in the backtest is good at first, but after a while, the speed decreases drastically. How should I solve this problem? Thank you for your guidance

We can't see your code. We can't see you computer. We can't read your mind!

So, all we can say is that you have problems with your code. What those problems are, we can't say.

 
Alireza Saadatinia:

Hello everyone, I have written an EA. The speed of EA in the backtest is good at first, but after a while, the speed decreases drastically. How should I solve this problem? Thank you for your guidance

From this single information you provided us it seems that you are working with OrdersHistoryTotal, so backtest is fast at the beginning of backtest when history trades is almost empty, and calculation time increases when closed trades increases. 

Just a supposition, it can be wrong because we don't see your code.
 
Fabio Cavalloni #:
From this single information you provided us it seems that you are working with OrdersHistoryTotal, so backtest is fast at the beginning of backtest when history trades is almost empty, and calculation time increases when closed trades increases. 

Just a supposition, it can be wrong because we don't see your code.

It is true. I use it to calculate profit and loss performance.

How should I display the profit and loss performance of the EA on the chart so that the speed does not decrease?

 
Alireza Saadatinia #:

It is true. I use it to calculate profit and loss performance.

How should I display the profit and loss performance of the EA on the chart so that the speed does not decrease?

Disable that function in tester, from what it seems it's usefull only for real time operation. On backtest you don't need that so you can save all that precious time...
 

Under the tab Debug of the editor you find Profiling with historic data and Profiling with actual data. 

This shows you weher and why your EA is so slow...

 
Alireza Saadatinia: but after a while, the speed decreases drastically. How should I solve this problem?
  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.)