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 opened more than one buy and one sell?
 Post subject: How to opened more than one buy and one sell? Post rating: 0   New post Posted: Fri 17 Dec, 2010, 12:30 

User rating: 0
Joined: Thu 02 Dec, 2010, 10:43
Posts: 2
Hi,

How do I have to modify the method I'm using to submit order to be able to open for example a second or third BUY position without the first and second one are already closed (which is now the case, JFException is :"cannot create order with label that already exists")?
I tried differents ways, i.e. get label order or get id label.

Here is the part of the concern code:

engine.submitOrder ("BUY", instrument, OrderCommand.BUY, amount, 0, 5, tick.getBid() - instrument.getPipValue() * 50, tick.getBid() + instrument.getPipValue() * 60);

Thank's


 
 Post subject: Re: How to opened more than one buy and one sell? Post rating: 0   New post Posted: Fri 17 Dec, 2010, 13:40 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
An order must be created with unique label, you can add a counter to your "BUY" label. Or you can create your method which will returns the order label, for example:
    private int counter = 0;
    protected String getOrderLabel(Instrument instrument) {
      String label = instrument.name();
      label = label + (counter ++);
      return label;
    }

Then consider the following code, to submit the order:
engine.submitOrder (getOrderLabel(Instrument instrument), instrument, OrderCommand.BUY, amount, 0, 5, tick.getBid() - instrument.getPipValue() * 50, tick.getBid() + instrument.getPipValue() * 60);


 

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