How to improve backtest speed

Posted By: easyX

How to improve backtest speed - 12/13/17 00:08

Hi, i am testing Zorro at the moment, doing some backtest speed tests.

My setting is a simple script entering one trade per day at a certain time and closing the trade at the same day (also fixed time). The test is with M1 bars.

Now i tested a bit.. first simple script took me 3 min to test it (8 years). Removing Monte Carlo made it much shorter already (for quick tests i dont need that, only for close-to-final tests).

Now i used Bar+=15 (skipping bars) - before, (between) and after my (fixed) trading times. This reduced backtest speed to just ~ 20s BUT this method makes the Result Graph buggy (blue equity chart is missing many bars)


I figured out that every run() is taking some time, so i would like to know if there is an option to skip everthing for e.g certain hours of the day.
So it would just run - run() during my market hours where i want to trade. StartMarket doesn't seem to work this way,
it does not increase the performance. Is there a way to do so? Are there any other tricks and tips for backtest performance?
Posted By: Petra

Re: How to improve backtest speed - 12/13/17 05:14

Its no good idea to skip bars, because you get gaps in all plotted curves and your indicators are wrong. No surprise that your graph looks bad. Historical data has anyway only bars where prices change, better don't miss them in the backtest.

For realistic backtests with M1 bars you normally need tick data, M1 data is not precise enough.
Posted By: easyX

Re: How to improve backtest speed - 12/13/17 10:50

The point is, sometimes i need/want to enter a trade e.g 11:52 no matter of everthing else, so i need m1 data, but not to be precise enough. I am more then happy with M1 OHLC data, i just like to double check with tick data at the end, but its not a big difference.

The point is just with all run()'s of M1, even if you do nothing during 99.9% of all cases, it slows down the backtest speed frown It's not faster then mql5 with this basic setup. smirk

So there is no way to tell my script hours where it does not trade and not even to run the run() function? Like the skip monday thing.
© 2024 lite-C Forums