Dukascopy
 
 
Wiki JStore Search Login

Attention! Read the forum rules carefully before posting a topic.

    Submit JForex API bug reports in this forum only.
    Submit Converter issues in Converter Issues.
    Off topics are strictly forbidden.

Any topics which do not satisfy these rules will be deleted.

engine.getOrder(String label) not working properly
 Post subject: engine.getOrder(String label) not working properly Post rating: 0   New post Posted: Thu 29 Jan, 2015, 10:02 
User avatar

User rating: 0
Joined: Thu 29 Jan, 2015, 09:25
Posts: 3
Hi,

I recently experimented a issue when deploying strategies in Dukascopy using my custom Java platform.

I have several strategys that use technical analysis to Open and Close Positions.
Each strategy can only open a position at a time, i give it an unique Label, so i can get the orders for that strategy using.

For trying i put this code onStart of the strategy. (The variables are all defined)

ITick lastTick = history.getLastTick(myInstrument);
double sl = lastTick.getAsk() - myInstrument.getPipValue() * stopLossPips;
double tp = lastTick.getAsk() + myInstrument.getPipValue() * takeProfitPips;
IOrder order = engine.submitOrder(this.labelStrategy, myInstrument, orderCommand, 0.001, 0, slippageAmount, sl, tp);


It opens a position with that label, I can see in JForex, and if i try the method
engine.getOrder(this.labelStrategy) 

it returns the order.

Now I stop the strategy and my Java Platform. I change the onStart method of the strategy and put this code

//ITick lastTick = history.getLastTick(myInstrument);
//double sl = lastTick.getAsk() - myInstrument.getPipValue() * stopLossPips;
//double tp = lastTick.getAsk() + myInstrument.getPipValue() * takeProfitPips;
//IOrder order = engine.submitOrder(this.labelStrategy, myInstrument, orderCommand, 0.001, 0, slippageAmount, sl, tp);
IOrder order = engine.getOrder(this.labelStrategy);


I launch the platforma and reconnect again to Dukascopy.
I just try to get the position i opened befored which is still opened, but i dont get any order and it returns me null.

I think this method was working fine several weeks ago.

Thanx in advance


 
 Post subject: Re: engine.getOrder(String label) not working properly Post rating: 0   New post Posted: Fri 30 Jan, 2015, 12:56 
User avatar

User rating: 164
Joined: Mon 08 Oct, 2012, 10:35
Posts: 676
Location: NetherlandsNetherlands
Hi,

If you iterate through your orders, do you also get back NULL?
        for (IOrder order : engine.getOrders()) {

        }


If the above code finds the order that was filled in previously, then there is something wrong with your "labelStrategy" object (not being initialized properly at the 2nd run, or something like that).
If engine.getoRders() also returns null, then it is probably a bug (as you also indicated).


 
 Post subject: Re: engine.getOrder(String label) not working properly Post rating: 0   New post Posted: Fri 30 Jan, 2015, 13:55 
User avatar

User rating: 0
Joined: Thu 29 Jan, 2015, 09:25
Posts: 3
Hi tcsabina

First, thanx for anwsering

Yes, the other instruction works fine and gets all opened orders.
The problem is i have a portfolio of more than 100 robots trading in different instruments which only open 1 position at a time.

Each robot has a label, which is unique for it and is pre-assigned.
So in each bar i check if i have the order open, and also check some technical indicators to open (if the order is not opened) or close (if the order is opened), but always there must be 1 position of the same robot at a time

The problem is in performance. Because on each 1 hour Bar i have all the robots working.
So each robot has to loop for all positions and check if he has a position opened or not.

I waste several seconds processing these instructions for all robots and i have the risk of big slipagges between the close price of the bar and the moment when i open position.

Thats why this method is perfect for my purposes, because it returns me the order i need for each robot.


 
 Post subject: Re: engine.getOrder(String label) not working properly Post rating: 0   New post Posted: Mon 02 Feb, 2015, 13:16 
User avatar

User rating: 164
Joined: Mon 08 Oct, 2012, 10:35
Posts: 676
Location: NetherlandsNetherlands
Hi,

Could you post your strategy (or at least a simplified one) that replicates the case?

Is the unique label (or some parts of it) not being changed between strategy execution? Is the label for a particular strategy is always looks the same?
If you execute engine.getOrder(label) right away you have submitted the strategy gives back the correct order? So the problem only exists if you restart the strategy?

These are just question to help to locate the problem...


 
 Post subject: Re: engine.getOrder(String label) not working properly Post rating: 0   New post Posted: Wed 04 Feb, 2015, 08:37 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi Jotas!

We could not replicate this issue, please provide the strategy or (if you use SDK) application+strategy pair that replicates the issue.


 

Jump to:  

  © 1998-2024 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