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.

Need Help With Pending Orders
 Post subject: Need Help With Pending Orders Post rating: 0   New post Posted: Thu 23 Dec, 2010, 15:30 
User avatar

User rating: 0
Joined: Tue 07 Dec, 2010, 10:51
Posts: 39
Hello everyone,

I'n trying to send pending orders, a long order and a short order at the same time. Sometimes both orders go through, other times only one of the two orders go through. I need to find a fix for this not sure what is wrong. See for some example code below.

I'm sending both stop and limit orders, for if the one fails the other one will fill. It also doesn't solve my problem. Any help will be appreciated!


      double PipVal = instrument.getPipValue();

                double LongPrice = askPrice + 30*PipVal;
           double LongSL = LongPrice - 20*PipVal;
           double LongTP = LongPrice + 20*PipVal;
           
           double ShortPrice = bidPrice - 30*PipVal;
           double ShortSL = ShortPrice + 20*PipVal;
           double ShortTP = ShortPrice - 20*PipVal;
           
           sendorder(instrument, engine, ShortTP , ShortSL, volume,ShortPrice,IEngine.OrderCommand.SELLSTOP);
           sendorder(instrument, engine, LongTP , LongSL, volume,LongPrice,IEngine.OrderCommand.BUYSTOP);

           sendorder(instrument, engine, ShortTP , ShortSL, volume,ShortPrice,IEngine.OrderCommand.SELLLIMIT);
                sendorder(instrument, engine, LongTP , LongSL, volume,LongPrice,IEngine.OrderCommand.BUYLIMIT);
           

   
    //+------------------------------------------------------------------+
    //| Send Orders Function                                             |
    //+------------------------------------------------------------------+
   
    public void sendorder(Instrument instrument, IEngine engine, double TakeProfit, double StopLoss, double volumeParam,double price,IEngine.OrderCommand OrderType)  throws JFException
    {
       
       IOrder pendingOrder = engine.submitOrder(getLabel(instrument),instrument,OrderType,volumeParam,price,10,StopLoss,TakeProfit);
       pendingOrder.waitForUpdate(30000);

    }


 
 Post subject: Re: Need Help With Pending Orders Post rating: 0   New post Posted: Mon 27 Dec, 2010, 10:23 
User avatar

User rating: 0
Joined: Tue 07 Dec, 2010, 10:51
Posts: 39
Think I found my problem I did not round my takeprofit and stoploss prices to five decimals... What a waste of two days hard work and not notice such a silly error :oops:


 

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