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.

isLong & getOpenPrice
 Post subject: isLong & getOpenPrice Post rating: 0   New post Posted: Sun 02 Jan, 2011, 03:46 

User rating: 0
Joined: Tue 15 Sep, 2009, 00:44
Posts: 20
Can someone show me some sample code on how to implement isLong & getOpenPrice methods?
I am trying to identify whether an existing order is long or short and get the original open price in order to set a new stop loss.


 
 Post subject: Re: isLong & getOpenPrice Post rating: 0   New post Posted: Sun 02 Jan, 2011, 13:02 

User rating: 0
Joined: Tue 27 Jul, 2010, 20:57
Posts: 49
Ok I have some spare time so..

First of all, you have to obtain the order, e.g. by label like so:

IOrder order = engine.getOrder(String label); //Returns order by label, or null if no order was found

Then you proceed with:
if (order != null)
   if (order.isLong()){
        double openPrice = order.getOpenPrice();
        ...
  }

Pretty straightforward.. How about reading the api here: https://www.dukascopy.com/client/javadoc//


 
 Post subject: Re: isLong & getOpenPrice Post rating: 0   New post Posted: Tue 04 Jan, 2011, 16:48 

User rating: 0
Joined: Tue 07 Dec, 2010, 15:50
Posts: 17
if you don't know precisely the label of your order you can use this:

for (IOrder order : engine.getOrders(instrument)) {
       if (order.isLong()) {
           double openPrice = order.getOpenPrice();
    }
}


 

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