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.

How to keep the strategy running after getting an exception
 Post subject: How to keep the strategy running after getting an exception Post rating: 0   New post Posted: Thu 20 May, 2010, 17:24 

User rating: 0
Joined: Sun 29 Nov, 2009, 04:15
Posts: 11
I am seeing my strategy stopped once an exception was thrown. So far I saw two, one is about canceling an order in "Created" status, which I could add a checking. Another is about updating the open price of an order. Actually I already had the status checking before the updating, what I guess is the order happened to be filled right after the checking and before the updating, looks like a timing issue cannot avoid. So should I wrap my code with try/catch block to keep the strategy running? Or there are other better ways?
Thank!


 
 Post subject: Re: How to keep the strategy running after getting an except Post rating: 0   New post Posted: Fri 21 May, 2010, 08:47 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Yes, there is. Open Tools->Preferences->Advanced. There is check box Stop strategies on exception. It need to be unchecked.


 
 Post subject: Re: How to keep the strategy running after getting an except Post rating: 0   New post Posted: Thu 27 May, 2010, 07:30 

User rating: 0
Joined: Fri 07 May, 2010, 02:59
Posts: 61
I was running into a similar issue last week. A few things you might look out for:

:- The GUI tester automatically handles crosses for you (eg, GBP/JPY) by splitting them out into two pairs you trade on simultaneously, but if you're using the TesterFactory/ITesterClient stuff the orders will never leave the CREATED state when you place them.
:- I don't remember what the exception was, but it might've been the exception you mentioned so I'll say this one just in case: If you're running your strategy from a different thread, you cannot close an order from your thread; it must be in the same thread onBar and onTick run in. Instead, you need to use IContext.executeTask to pass in an instance that'll close the order for you in the onBar and onTick thread.
:- Use IOrder.waitForUpdate after attempting to make a change to the state of an order (cancel, create, etc). This will make sure the order is not in the CREATED state before you move on, so you can avoid the kind of race condition you mentioned.

-Brian


 

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