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.

one order
 Post subject: one order Post rating: 0   Post Posted: Sat 16 Jun, 2012, 11:42 
User avatar

User rating: 1
Joined: Fri 02 Mar, 2012, 13:19
Posts: 31
Location: PolandPoland
Hi,
I would like to know how to make only one trade per Bar. If one trade is opened in current bar, wait until next bar.
thanks


 
 Post subject: Re: one order Post rating: 0   Post Posted: Mon 18 Jun, 2012, 08:21 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Consider doing something like this on your order creation:
    private int orderCounter;
    private void makeOrder(Instrument instrument, Period period) throws JFException {
        IBar bar = history.getBar(instrument, period, OfferSide.BID, 0);
        for(IOrder order : engine.getOrders(instrument)){
            if(order.getCreationTime() > bar.getTime()){
                console.getOut().println("There is an order already opened within the current bar for "+instrument);
                return;
            }
        }
        console.getOut().println("active orders: " + engine.getOrders(instrument));
        engine.submitOrder("order"+ ++orderCounter, instrument, OrderCommand.BUY, 0.001);
    }


Attachments:
OneTradePerBar.java [1.8 KiB]
Downloaded 288 times
DISCLAIMER: Dukascopy Bank SA's waiver of responsability - Documents, data or information available on this webpage may be posted by third parties without Dukascopy Bank SA being obliged to make any control on their content. Anyone accessing this webpage and downloading or otherwise making use of any document, data or information found on this webpage shall do it on his/her own risks without any recourse against Dukascopy Bank SA in relation thereto or for any consequences arising to him/her or any third party from the use and/or reliance on any document, data or information found on this webpage.
 

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