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.

Strategy thread queue overloaded with tasks
 Post subject: Strategy thread queue overloaded with tasks Post rating: 0   Post Posted: Tue 05 Oct, 2010, 04:03 

User rating: 1
Joined: Tue 05 Oct, 2010, 03:49
Posts: 6
Hello,

First off, thanks very much for the forum; it's very helpful!

So I'm running my strategy on a demo account for the October Strategy contest, and I'm getting some messages I had not seen before while I was developing the strategy. The message is:

"Strategy thread queue overloaded with tasks. Ticks in queue - 5, bars -470, other tasks - 131"

I tried searching for an answer in this forum but didn't find an answer, so maybe this is not very common? I wonder if this has to do with my computer, of the code in the strategy, or the dukascopy server... I'm running my strategy on a rather old desktop computer, so I'm guessing it might be my machine. I use another faster (laptop) computer to develop and I never saw this before.

Any clues as to what could be causing this and solutions to fix this would be most appreciated.

Sincerely,

T.


 
 Post subject: Re: Strategy thread queue overloaded with tasks Post rating: 0   Post Posted: Tue 05 Oct, 2010, 08:14 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hello,
this message say's that your strategy's thread is busy and the onBar method can't execute. At the moment there is 470 bars, that waiting for an execution. If this count will reach 2000, then the error message will be shown. To resolve a problem, you must run your calculation in a separate thread. Please consider this https://www.dukascopy.com/wiki/index.php/Threading


 
 Post subject: Re: Strategy thread queue overloaded with tasks Post rating: 0   Post Posted: Wed 06 Oct, 2010, 00:35 

User rating: 1
Joined: Tue 05 Oct, 2010, 03:49
Posts: 6
Thank you for your quick reply. I'll look into using separate threads.
I'd still like to know *why* this is happening, as my strategy is actually quite simple. I've looked at the code of four strategies that have participated in the strategy contest before and none use separate threads. Is it safe to conclude that a faster computer would be less likely to run into this problem? Also, does JForex automatically take advantage of multi-processors in a multi-processor machine? Does the use of separate threads automatically take advantage of multi-processors?

thanks again,

T.


 
 Post subject: Re: Strategy thread queue overloaded with tasks Post rating: 0   Post Posted: Thu 07 Oct, 2010, 10:06 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Tezcatlipoca wrote:
I'd still like to know *why* this is happening, as my strategy is actually quite simple

It happens when you use some long running operations that blocks the strategy thread. It could be thread sleeps, or wait or locks on sychronized code or some slow operations like network access. Can't say more specifically without seeing the code.
Tezcatlipoca wrote:
Is it safe to conclude that a faster computer would be less likely to run into this problem?

No, it's not. All computers that can run java are fast enough to work with strategy in real time. No matter how fast is your CPU, if you block the thread with Thread.sleep or something like that, then you get this problem.
Tezcatlipoca wrote:
Also, does JForex automatically take advantage of multi-processors in a multi-processor machine?

Nothing does take advantage of multi-processors automatically. If you use threads, if you have and do some jobs in parallel then it runs on multiple processors and cores simultaneously and takes advantage of them. JForex does use threads, we do many operations that can take some time in separate threads, like operations with network. But they are not CPU intensive and simple machine with one CPU and one core should be enough.
Tezcatlipoca wrote:
Does the use of separate threads automatically take advantage of multi-processors?

Yes it takes advantage and no it doesn't do it "automatically". It depends on the jobs that the threads are doing. If thread does some CPU intensive operation then it takes advantage. If thread starts and waits for some event then it doesn't take advantage, because it's not running most of the time anyway.

You sould find the place where and why strategy thread is blocked, why it doesn't process bars like it should. Then you should rewrite that place in some other way to resolve the problem. The use of the threads can help, but maybe you just need to handle your situation in some other way. What you should do is not to block thread. It enters one of the methods like onTick and it should exit from it to be able to process next event, next bar or tick.


 
 Post subject: Re: Strategy thread queue overloaded with tasks Post rating: 0   Post Posted: Thu 07 Oct, 2010, 16:42 

User rating: 1
Joined: Tue 05 Oct, 2010, 03:49
Posts: 6
Hello Support,

Thanks again for your careful reply.
I'll see how I can re-code my strategy more efficiently.

:idea:
Apart from this, it occurred to me that it would be very nice to have a section in the forum (maybe a sub-section in the Strategy Contests section) specifically intended for people to submit their code for revision/critique by others, and where any other developer can submit improvements to the code.

best,

T.


 
 Post subject: Re: Strategy thread queue overloaded with tasks Post rating: 0   Post Posted: Thu 07 Oct, 2010, 16:43 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Please take a look at this section: https://www.dukascopy.com/swiss/english/forex/jforex/forum/viewforum.php?f=7


 

Jump to:  

cron
  © 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