Download MetaTrader 5

Backtesting slowing to a crawl

To add comments, please log in or register
TheLobos 2016.06.06 09:53 

I'm backtesting some EAs and while things used to be nice and fast, as of lately things have slowed down to a crawl. 

When I'm backtesting in visual mode, I initially see bars being placed very rapidly but then after about 30 seconds or so, it slows down to a crawl. This happens on my EAs and also seems to happen on all other EAs I've downloaded and tested.

Interestingly enough, on my EAs (where I actually know for sure how they are coded) this happens before any orders are opened. As such, it's not a matter of my EAs doing weird stuff (since they have no orders to process and are coded to only trade (and recompute indicators) upon the completion of a bar. I've inserted some tracing code and the EA is exiting/returning on non-complete bars right at the start of the EA). 

Also, sometimes the visual graph sometimes shows bursts of faster activity (for about a second or so) and then it slows down again. I have imported external history data into the history center and converted it using the period converter. I did this months ago and it's been running fine/fast until about a week ago. All of this leads me to believe that it's somehow an MT4 related issue. 

Does anybody have any ideas as to why this might be happening because I've been unable to figure out the source of this issue. 

Thanks for any tips. 

Carl Schreiber
Carl Schreiber 2016.06.06 10:51  

Check the code of the EA. To me it sounds as if all the time everything for each bar is calculated or the amount of graphical objects is increasing (still guessing!).

Use the profiler to find out why..

Fernando Carreiro
Fernando Carreiro 2016.06.06 12:19  

Most of the "free" EA's you find on the Internet suffer from a "flawed" implementation problem and your EA may too.

As "gooly" pointed out, the slow down may be because you may be executing ALL of your logic on EVERY SINGLE TICK event.

Divide your tasks into those that only need to be updated or calculated when a NEW BAR is detected and those events that need to be checked on every TICK. Even for the NEW BAR events, don't recalculate everything again, just update the calculations that are needed.

If you do this correctly, you will suddenly see a BIG BOOST in speed on your EA. However, without submitting an sample code, how do you expect us to offer any other help?

whroeder1 2016.06.06 13:00  
You may also have indicators that update all bars each tick. Try reducing bars on chart (not in history) to something reasonable (like 1K.)
To add comments, please log in or register