Optimizing EA for a faster strategy tester

 

i have included this indicator into my EA.However, after including it , strategy tester became so slow , it barley moves !!

Indicator used : https://www.mql5.com/en/code/19825

Can anyone help me find how to optimize it or anyway to accelerate the testing?

Modified Keltner Channel
Modified Keltner Channel
  • www.mql5.com
The indicator draws the Keltner Channel, which can be calculated using SMMA, EMA and LWMA. Channel borders are calculated based on High-Low or ATR. Smoothing periods for the central line and channel border lines are also configurable. It has six input parameters: Number of the periods to smooth the center line - central line smoothing period...
 
  1. andrw11: i have included this indicator into my EA.

    Don't try to do that. There are no buffers, no IndicatorCounted() or prev_calculated. No way to know if older bars have changed or been added (history update.)

    Just get the value(s) of the indicator(s) into EA/indicator (using iCustom) and do what you want with it.

    You should encapsulate your iCustom calls to make your code self-documenting.
              Detailed explanation of iCustom - MQL4 programming forum #33 2017.05.23

  2. andrw11: Can anyone help me find how to optimize it or anyway to accelerate the testing?
    1. EAs : Don't do per tick that 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 open or close, only look when OrdersTotal (or MT5 equivalent) has changed.
                How to get backtesting faster ? - MT4 - MQL4 programming forum 2017.08.07

    2. Indicators: Code it properly so it only recomputes bar zero (after the initial run.)
                How to do your lookbacks correctly. 2016.05.11
      Or, reduce Tools → Options (control+O) → Charts → Max bars in chart to something reasonable (like 1K.)

 
William Roeder:
  1. Don't try to do that. There are no buffers, no IndicatorCounted() or prev_calculated. No way to know if older bars have changed or been added (history update.)

    Just get the value(s) of the indicator(s) into EA/indicator (using iCustom) and do what you want with it.

    You should encapsulate your iCustom calls to make your code self-documenting.
              Detailed explanation of iCustom - MQL4 programming forum #33 2017.05.23

    1. EAs : Don't do per tick that 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 open or close, only look when OrdersTotal (or MT5 equivalent) has changed.
                How to get backtesting faster ? - MT4 - MQL4 programming forum 2017.08.07

    2. Indicators: Code it properly so it only recomputes bar zero (after the initial run.)
                How to do your lookbacks correctly. 2016.05.11
      Or, reduce Tools → Options (control+O) → Charts → Max bars in chart to something reasonable (like 1K.)

Thanks a lot for your help 

1. i have already included the indicator using an iCustom function. 

2.
    1- so as in your code example , i should put all my code (calculations and indicators) inside the IF statement of "isnew bar" ?

     and regarding orders , i have already mentioned that if (signal="buy" && orderstotal < 2 ) then execute a buy order 

     2- i'm not quite sure i understand the code mentioned ! but i have tried the second option of reducing "Max bars" and it's slightly faster 

Reason: