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.

Problem with STOP entry order
 Post subject: Problem with STOP entry order Post rating: 0   New post Posted: Thu 03 Oct, 2013, 14:24 

User rating: 0
Joined: Thu 23 May, 2013, 10:24
Posts: 3
Location: SwitzerlandSwitzerland
Hello,

I'm trying to build a strategy where the entry order is via BUY STOP / SELL STOP oder. My problem is that my orders are filled in marketprice. For example, I use the following command to issue the Buy stop order:

myOrder = engine.submitOrder(label, myInstrument, OrderCommand.BUYSTOP, pos_size, 153.794,5);


In this moment the market price is 154.494. After the command is executed, I receive the following message in onMessage method:
ORDER_SUBMIT_OK - Order submitted order: OPENED BUYSTOP 0.002 @ 153.794
so it seems that my order was accepted OK

The problem starts, when my order gets filled as the order is filled on market price and not on the desired stop price:
Message: ORDER_FILL_OK - Order filled order: FILLED BUY 0.002 @ 154.494

Any idea what am I doing wrong?


 
 Post subject: Re: Problem with STOP entry order Post rating: 0   New post Posted: Thu 03 Oct, 2013, 17:17 
User avatar

User rating: 94
Joined: Mon 06 Feb, 2012, 12:22
Posts: 357
Location: Portugal, Castelo Branco
Hi Kkrisz:

You need to take in consideration the default slippage (you use 5), the spread and fast moves.

See https://www.dukascopy.com/wiki/#Slippage
and IOrder submitOrder(String label,
Instrument instrument,
IEngine.OrderCommand orderCommand,
double amount,
double price,
double slippage)
throws JFException

Trade well

JL

EDIT: seems you are using the incorrect orderCommand...

BUYSTOP
Buy when ask price is >= specified price


See https://www.dukascopy.com/client/javadoc ... mmand.html


 
 Post subject: Re: Problem with STOP entry order Post rating: 0   New post Posted: Fri 04 Oct, 2013, 09:47 

User rating: 0
Joined: Thu 23 May, 2013, 10:24
Posts: 3
Location: SwitzerlandSwitzerland
jlongo wrote:
Hi Kkrisz:

You need to take in consideration the default slippage (you use 5), the spread and fast moves.

...

EDIT: seems you are using the incorrect orderCommand...

BUYSTOP
Buy when ask price is >= specified price


Hi JL,

Thank you for your reply. I beleive I understand the concept of slippage and BUYSTOP/SELLSTOP command as well. Let me give you an example what I'm trying to do here:

// get the current price
double pivot = askBar.getClose();

// calculate 70 pips higher (for GBPJPY)
double S1 = pivot + 0.0070*100;

[...]

// and finally to place a SELLSTOP order. I want the SELL command to be executed when the price hits this higher level
myOrder = engine.submitOrder(label, myInstrument, OrderCommand.SELLSTOP, pos_size, S1,-1, stopLossPrice, 0);


Therefore I'm expecting the trade to be executed only, if the price starts to climb up and hits my BUY STOP price. But instead the trade is executed immediately with the market price. How is it possible?

Thanks,
Krisztian


 
 Post subject: Re: Problem with STOP entry order Post rating: 0   New post Posted: Fri 04 Oct, 2013, 11:36 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
See:
https://www.dukascopy.com/client/javadoc/com/dukascopy/api/IEngine.OrderCommand.html#BUYSTOP
https://www.dukascopy.com/client/javadoc/com/dukascopy/api/IEngine.OrderCommand.html#SELLSTOP
Hence, if you put a SELLSTOP above the market bid price, it is subject to immediate execution.


 

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