How to write fast working expert advisor?

 
how to write fast working expert advisor

hello, I wrote an expert of medium complexity, but his backtests are progressing very slowly. It tests 10 days in 20 minutes. It's very slow because maybe I'll have to test the last 5 years.

Some experts, which are more complex than mine, can be tested very quickly... There are even those who test 5 years in 30 minutes.

this means ; While I am coding the expert, I am choosing a wrong method somewhere..

I wonder if anyone can give me little tips on how to write an expert that can be tested quickly?
 
Ümit UYSAL:

Difficult to help without source code. 

But you can at least run the code per candle confirmation and not on every tick.

 
Yaşar Seyyidin # :

Kaynak kodu olmadan yardım etmek zor. 

Ancak en iletim kodu her onay işareti için değil, her onay işareti için çalıştırabilirsiniz .

For example, I wrote a simple function of my own that returns the number of open transactions by type.


number of buy transactions

number of sell transactions

buylimit...

Sellimit..

buystop

I calculate the number of sellstop orders separately.


because I have conditions for taking transactions according to these numbers when taking transactions.

For example, if the number of buys==3 and the number of buystops==0, then send a buystop order....


I think my expert is slowing down because the function that calculates these numbers goes to the terminal and receives data every time. how can i fix this?

 
Ümit UYSAL: but his backtests are progressing very slowly.
  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.)

Reason: