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.

Cancel All Pending Orders If One Order Fills
 Post subject: Cancel All Pending Orders If One Order Fills Post rating: 0   New post Posted: Wed 24 Oct, 2012, 23:08 

User rating: 3
Joined: Thu 17 Nov, 2011, 04:06
Posts: 39
Location: Canada, Ottawa
I am working with a strategy that can only deal with one filled order at a time, for money management purposes. I am trying to program a way to cancel all pending orders when one order fills. I have come up with this:

    public void onTick(Instrument instrument, ITick tick) throws JFException {
        // Cancelling Pending Orders If An Order Is Filled
        for (IOrder allOrders : engine.getOrders()) {
            if (allOrders.getState() == IOrder.State.FILLED) {
                for (IOrder order : engine.getOrders()) {
                    if (order.getState() == IOrder.State.OPENED) {
                        order.close();
                    }
                }
                break;
            }
        }
    }


Is there a more efficient way to program this?


 
The Best Answer  Post subject: Re: Cancel All Pending Orders If One Order Fills Post rating: 0   New post Posted: Thu 25 Oct, 2012, 07:41 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Rather no.


 

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