How to improve backtesting speed

 

Hello Everyone,

I have a set of 3 indicators with function as follow:

1. Signal indicator which will give buy/sell/TP/Sl point.

2. Filter indicator base on a lot of IF to give the confirmation of when to trade.

3. Trading EA will take the signal from the 2 indicator above and trade when signal + confirmation show up.

I want to improve the back test speed and I think that since the filter indicator contains too many IF, and it structure like:

int numberbars=Bars;

while(i<numberbars-5)

IF(cond1 || cond2 || cond3||) {buy=1;}

So I have to question that hope you can help:

1.I wonder if can I make any change to the While so that it can run faster. I imagine that I shouldn't have to recalculate too many bar.

2.I am not sure if I can combine all 3 code in 1 EA, but even if I try, do you think it will help?

Many thanks,

SCFX

 
scfx:

Hello Everyone,

I have a set of 3 indicators with function as follow:

1. Signal indicator which will give buy/sell/TP/Sl point.

2. Filter indicator base on a lot of IF to give the confirmation of when to trade.

3. Trading EA will take the signal from the 2 indicator above and trade when signal + confirmation show up.

I want to improve the back test speed and I think that since the filter indicator contains too many IF, and it structure like:


Read this thread from start to finish, it may help: https://www.mql5.com/en/forum/144240
 
while(i<numberbars-5)
means the indicator recalculates all bars every tick, even though only bar zero is changing. Do it right
int counted = IndicatorCounted();
if(counted < 5) counted = 5; // Don't look back past end of bars.
for(int i = Bars - 1 - counted; i >= 0; i--)
 

Thank you for you BIG TIPS!

SCFX

Reason: