Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Submit JForex API bug reports in this forum only.
    Submit Converter issues in Converter Issues.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

Indicator causes massive slowdown in backtest.
 Post subject: Indicator causes massive slowdown in backtest. Post rating: 0   New post Posted: Thu 28 Nov, 2013, 10:27 
User avatar

User rating: 0
Joined: Sun 22 Sep, 2013, 22:29
Posts: 18
Location: RomaniaRomania
I am using a simple open-price daily SMA as the main indicator for the strategy. It's calculated like this:
Quote:
indicators.sma(instrument,Period.DAILY, OfferSide.BID, IIndicators.AppliedPrice.OPEN, MAPeriod, 0)


And this is put inside an onBar() event, and checked at every period==Period.DAILY.

The backtest goes speedy, unless I put this indicator over the chart, to see what the strategy is doing.
I put it on the chart of the backtest (Daily chart, EUR/USD), Indicator price is Open price, period is 14.

The speed massively slows down. I even have to backtest without the indicator on the chart, because it takes forever with the indicator on chart.

When I started to backtest the strategy, I did with the indicator off the chart, and it was running fast. However, I forgot I did that in the beginning, and when I got to latter stages, I added the indicator. I was running on a friend's virtual machine with 2 cores allocated, but the speed drop was so significant that I cleared the registry, rebooted machine, got an extra core and extra memory and the drop is still significant. That's when I realised it was the on-chart indicator causing the issue.

Check the code for your indicator implementation. It probably recalculates at each tick, causing the massive slowdown, but it's open price, it shouldn't do that!


 
 Post subject: Re: Indicator causes massive slowdown in backtest. Post rating: 0   New post Posted: Thu 28 Nov, 2013, 12:31 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Please provide an example strategy which replicates the case. Also provide a screenshot of the Historical Tester settings that you use.


 
 Post subject: Re: Indicator causes massive slowdown in backtest. Post rating: 1   New post Posted: Thu 28 Nov, 2013, 14:43 
User avatar

User rating: 164
Joined: Mon 08 Oct, 2012, 10:35
Posts: 676
Location: NetherlandsNetherlands
a)
There is a checkbox for almost every indicator: Recalculate on new candles only.
You can try to enable it (if it isn't selected by default), and see if that makes any difference in speed.

b)
The platform's indicator sources are publicly available. You can check the source of SMA yourself.
https://www.dukascopy.com/wiki/#Platform ... urce_files

As the link in the wiki page is broken, here is the correct link to the latest sources:
https://www.dukascopy.com/client/jforexl ... I/2.9.4.1/

@Support:
Could you fix the broken link in the wiki page?

c)
As the Historical Tester itself is quite resource consuming, maybe this is normal. I use the tester on a i5-3570+16GB system running on SSD, but I also see performance decrease of the tester if I place an indicator that draws to the chart.
Keep in mind that the indicator calculation is probably not optimized for historical tester, where tick and candle creation is much more faster.

Hope this helps.


 
 Post subject: Re: Indicator causes massive slowdown in backtest. Post rating: 0   New post Posted: Thu 28 Nov, 2013, 22:27 
User avatar

User rating: 0
Joined: Sun 22 Sep, 2013, 22:29
Posts: 18
Location: RomaniaRomania
tcsabina wrote:
a)
There is a checkbox for almost every indicator: Recalculate on new candles only.
You can try to enable it (if it isn't selected by default), and see if that makes any difference in speed.

Hope this helps.


You nailed it! That was it. I didn't notice it in the beginning and I was convinced that since it's the open it won't recalculate at each tick.


 
 Post subject: Re: Indicator causes massive slowdown in backtest. Post rating: 0   New post Posted: Fri 29 Nov, 2013, 09:12 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
You only need to take into account that the value for the currently forming candle is not precise in such case.


 
 Post subject: Re: Indicator causes massive slowdown in backtest. Post rating: 0   New post Posted: Fri 29 Nov, 2013, 12:15 
User avatar

User rating: 0
Joined: Sun 22 Sep, 2013, 22:29
Posts: 18
Location: RomaniaRomania
API Support wrote:
You only need to take into account that the value for the currently forming candle is not precise in such case.


Since it uses the open, the opening bid (or ask?) will stay unchanged during the lifetime of the candle. Why would it be wrong ?


 
 Post subject: Re: Indicator causes massive slowdown in backtest. Post rating: 0   New post Posted: Fri 29 Nov, 2013, 12:35 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
In that particular case - yes, the value will be the same throughout the current candle's forming time.


 

Jump to:  

  © 1998-2024 Dukascopy® Bank SA
On-line Currency forex trading with Swiss Forex Broker - ECN Forex Brokerage,
Managed Forex Accounts, introducing forex brokers, Currency Forex Data Feed and News
Currency Forex Trading Platform provided on-line by Dukascopy.com