Dukascopy
 
 
Wiki JStore Search Login

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

    Try to find an answer in Wiki before asking a question.
    Submit programming questions in this forum only.
    Off topics are strictly forbidden.

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

Multi-Threaded Strategy + Historical Tester incompatibility
 Post subject: Multi-Threaded Strategy + Historical Tester incompatibility Post rating: 0   New post Posted: Mon 13 Dec, 2010, 06:40 

User rating: 0
Joined: Thu 02 Dec, 2010, 16:55
Posts: 15
Has anyone come up with a workaround that enables them to test a multi-threaded strategy?

Here's what I came across. As I offload calculations to other threads and don't block in the onBar/onTick methods, the historical tester keeps running full speed. By the time the calculation is finished, the historical tester is far ahead of the data that was calculated. So any decision to open/close a position comes late. The symptom is that each run on the historical tester yields different results with the same entry/exit conditions as different threads finish calculating at different times each run.

Is there any workaround for this?


 
 Post subject: Re: Multi-Threaded Strategy + Historical Tester incompatibil Post rating: 0   New post Posted: Tue 14 Dec, 2010, 14:28 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
You can call IEngine.getType and if it return TEST then run your jobs in the same strategy thread


 
 Post subject: Re: Multi-Threaded Strategy + Historical Tester incompatibil Post rating: 0   New post Posted: Thu 16 Dec, 2010, 18:07 

User rating: 0
Joined: Thu 02 Dec, 2010, 16:55
Posts: 15
I did understand that. I suppose it could be done if the main thread had to wait for all worker threads to finish before leaving onBar/onTick as well... which would enable multi-threading during testing?


 
 Post subject: Re: Multi-Threaded Strategy + Historical Tester incompatibil Post rating: 0   New post Posted: Mon 07 Feb, 2011, 15:04 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Yes, that's correct. If you do multiple tasks in parallel then it will be multi-threading, but if the strategy thread will wait for the only one thread, then it's sequential execution in multiple thread, no parallel execution in this case.


 

Jump to:  

  © 1998-2025 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