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.

PLACE_BID one pip from the current market price
 Post subject: PLACE_BID one pip from the current market price Post rating: 0   New post Posted: Tue 03 Aug, 2010, 17:30 

User rating: 0
Joined: Wed 07 Jul, 2010, 17:54
Posts: 10
Dear support,

I am trying to incorporate PLACE_BID/PLACE_OFFER to my strategy, but having some problems.

The simple BUY order would look something like this:

order = engine.submitOrder(getLabel(), instrumentas,IEngine.OrderCommand.BUY, 0.01);

Accordingly, PLACE_BID would look something like this:

order = engine.submitOrder(getLabel(), instrumentas,IEngine.OrderCommand.PLACE_BID, 0.01, 1.5367);

As you can see, I can only make PLACE_BID at a specified price only (1.5367 in this example). How could I make it that the PLACE_BID would be put one pip from the current market price all the time? I mean, if the buy condition is met, it would just take the current market price and place bid one pip from it. Could you give me some ideas or sample code?

Thank you,
Sarunas


 
 Post subject: Re: PLACE_BID one pip from the current market price Post rating: 0   New post Posted: Wed 04 Aug, 2010, 08:20 

User rating: 0
Joined: Tue 27 Jul, 2010, 20:57
Posts: 49
Edit


 
 Post subject: Re: PLACE_BID one pip from the current market price Post rating: 0   New post Posted: Wed 04 Aug, 2010, 09:24 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Hi,
You can use the following to place bid order at the current market price:
order = engine.submitOrder("label", instrument, IEngine.OrderCommand.PLACE_BID, amount, 0); 

Also, you can extract the value of the last tick from history:
history.getLastTick().getAsk() or history.getLastTick().getBid() 
and use it to calculate the required price for the above bid order:
double price = history.getLastTick(instrument).getBid() + 1 * instrument.getPipValue();
where instrument variable represents the instrument you use.


 

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