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.

order.waitForUpdate not working in remote server?
 Post subject: order.waitForUpdate not working in remote server? Post rating: 0   New post Posted: Fri 03 Dec, 2010, 04:28 

User rating: 1
Joined: Fri 26 Mar, 2010, 19:19
Posts: 116
Location: Canada
I just noticed that my opened position in the contest has no trailing stop. The order was opened on the remote server. When I tested it locally, the trailing stop was working. Could the fact that my strategy is running in the remote server be causing the problem because I'm using order.waitForUpdate(800) immediately after opening the order? Here's the code.

            order = engine.submitOrder(label, instrument, IEngine.OrderCommand.BUY, 
               lot, 0, SLIPPAGE, stopLoss, takeProfit);                  
            order.waitForUpdate(800);
            order.setStopLossPrice(stopLoss, OfferSide.BID, trailStep);


Would increasing the timeout help?


 
 Post subject: Re: order.waitForUpdate not working in remote server? Post rating: 0   New post Posted: Mon 06 Dec, 2010, 15:13 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
After submitting the order please consider the following code to change order state:
while (!IOrder.State.FILLED.equals(order.getState()) && !IOrder.State.CANCELED.equals(order.getState())) {
    order.waitForUpdate(800);
}
if (IOrder.State.FILLED.equals(order.getState())) {
    order.setStopLossPrice(stopLoss, OfferSide.BID, trailStep);
}


 
 Post subject: Re: order.waitForUpdate not working in remote server? Post rating: 0   New post Posted: Mon 06 Dec, 2010, 15:44 

User rating: 1
Joined: Fri 26 Mar, 2010, 19:19
Posts: 116
Location: Canada
thanks, I considered this but did't want to wait too long in the main thread. I guess it's the only way.

in case anyone else is reading this, I suggest a FOR loop with a bound just so this doesn't wait forever and crash your strategy.


 

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