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 successive order
 Post subject: One successive order Post rating: 0   New post Posted: Fri 06 May, 2011, 06:44 

User rating: 0
Joined: Mon 18 Apr, 2011, 11:21
Posts: 6
Hello support,
Here is my problem :

I'am building a strategy on tick method based on price. The strategy can open only one trade at the same time. What I want is that if one trade is open and doing well, to open a second trade in the same direction but at a different price.
How do I code this ? Do I have to use "waiting" method to indicate to the strategy to open a trade for one price and wait a second different price to open a second trade ?
For instance : a first buy at 1.4500 and then a second buy at 1.4505.
A code example will be very welcome.
Thank you and have a nice day


 
 Post subject: Re: One successive order Post rating: 0   New post Posted: Mon 09 May, 2011, 09:28 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
It all depends on what you mean by "doing well", if you simply wish to make sure the first order was filled before submitting the second order you can use the code similar to the one below:
...
IOrder order = null;                                 
order = engine.submitOrder("First", Instrument.EURUSD, OrderCommand.BUY, 0.001, 0); //market order
while (order.getState() == IOrder.State.CREATED || order.getState() == IOrder.State.OPENED) {
  order.waitForUpdate(1, TimeUnit.SECONDS);
}             
         
if (order != null && order.getState() == State.FILLED){
  //submit the second order           
}


 

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