MQL4 - automated forex trading   /  

Forum

[Strategy Tester] execution speed slowing down exponentially while backtesting an EA

Back to topics list To post a new topic, please log in or register

avatar
242
schnappi 2010.02.08 17:27 

Has anyone found out, what it is that's slowing down the strategy tester?

On the one hand I have rather complex EAs that I can backtest in around 10 sec / month. Some other EAs really slow down the strategy tester exponentially and take >1 min/month. I haven't yet ofund out what it is: RAM usage stays on a constant level so it's not a memory leak then.

article

Sending Trade Signal Via RSS Feed

This is my idea how to send your trade signal as RSS FEEDS , a famous way to communicate with your community's members right now.


avatar
1235
BarrowBoy 2010.02.08 18:26 

Much depends on what is being done & when

Do some evaluate open or close only on first tick of a bar and others check each tick?

Is something being done ecah tick that you think is once per bar?

Do some have 'indicator code' in the EA & others sub the code to an external indicator?

These are the most common things I see with 'slow' EA's..

FWIW

-BB-


avatar
316
blogzr3 2010.02.08 19:05 

99.9% of the time, it is due to inefficient code.


As for the remainder, I'm not sure :)


avatar
355
WHRoeder 2010.02.08 19:52 
int init() {
  if ( IsTesting() && !IsVisualMode() ) { Show.Objects	= false;	// test
					  Show.Comments	= false;	}
  //...
}
//...
	if (Show.Comments) {
		Comment(//...


avatar
1188
cloudbreaker 2010.02.08 19:55 

Backtest performance will be especially hampered if there is logic performed with each tick such as:

- repetitive logic eg. looping logic through order history

- logic with latency eg. file access, dll access

- heavyweight logic eg. complex calculations with many variables

- poorly written logic

Depending upon your EA, it can make sense to create a LIVE and TEST mode, configurable by an extern variable, in order to allow certain functionality to be bypassed for strategy tester runs.


CB



avatar
242
schnappi 2010.02.09 00:02 

BB/WHRoeder/CB: Thank you for your support.


My reference time was 62 seconds for 1 month in the backtest.


What I've found out this afternoon:

- deleted unused code (code that will never be executed) --> -2 sec

- deactivated all kinds of graphical objects --> -3 sec

- added an exit at the very beginning when I can be sure that there's "nothing to do" on this tick --> -12 sec

- removed some unneccessary function calls --> -4 sec

- (don't know if that's correct english:) I've interleaved connected boolean operators --> -4 sec


--> all in all i nearly doubled the performance


what I've found out: MQL does not handle connected boolean operators like i.e. Java.

example:

if (cond1 && cond2 && cond3...)

--> all conditions will be checked, even if cond1 is false


so what I did is this:

if (cond1) {

if (cond2) {

and so on ...

}

}

ugly, but so is MQL...


also unnecessary function calls are able to reduce the execution speed significantly- I always underestimated this fact. but again, it's MQL...


avatar
355
WHRoeder 2010.02.09 18:08 

I can confirm this if the second condition is a function call, the function is called. However, I haven't seen

v!=0 && x/v...

Back to topics list  

To add comments, please log in or register