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.

order.getLabel() problem
 Post subject: order.getLabel() problem Post rating: 0   New post Posted: Thu 24 Sep, 2009, 16:38 

User rating: 0
Joined: Thu 06 Sep, 2007, 13:58
Posts: 4
Hi folks,

I have following problem which I will describe chronologically:

1. My System labels orders e.g. long-orders are labeled "long" and short-orders "short". For example: engine.submitOrder("long", ...)
2. Now a long position is opened, with the label "long".
3. When I count my filled long-positions filtered with order.getLabel(), my system recognizes the long-position and returns "1":
//This code returns "1" before JForex restart and "0" after restart.
    protected int longPositions(Instrument instrument) throws JFException {
        int counter = 0;
        for (IOrder order : engine.getOrders(instrument)) {
            if (order.getState() == IOrder.State.FILLED && order.getLabel() == "long") {
                counter++;
            }
        }
        return counter;
    }

4. Now I close the Jforex-Platform (the long position is still open) and restart the platform.
5. When I count the long-positions again, it returns "0" for long-positions. But the order and its label is still there.

Why is the label after JForex restart not recognized anymore? Does anyone know how to solve this problem?

Thx

- Fuzzy


 
 Post subject: Re: order.getLabel() problem Post rating: 0   New post Posted: Fri 25 Sep, 2009, 08:25 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
because IOrder.getLabel() returns String, comparison like " order.getLabel() == "long" " in java compares pointers not object values. Instead you should use String equals(), for example " order.getLabel().equals("long") " .


 

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