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.

How to set stop-loss and take-profit as a function of current spread
 Post subject: How to set stop-loss and take-profit as a function of current spread Post rating: 0   New post Posted: Mon 22 Oct, 2012, 03:55 

User rating: 0
Joined: Tue 16 Oct, 2012, 12:23
Posts: 40
I want to set the stop-loss and take-profit as a function of the current spread. They should be variable and not constant. The stop-loss and take-profit should be 10 times the current spread. Could you please tell me how to do it? Also plz tell me how to fetch the current spread value. Thanks.


 
 Post subject: Re: How to set stop-loss and take-profit as a function of current spread Post rating: 0   New post Posted: Mon 22 Oct, 2012, 07:24 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
Consider the following approach:
ITick tick = history.getLastTick(Instrument.EURUSD);
double stread10Times = (tick.getBid() - tick.getAsk()) * 10;
See:
https://www.dukascopy.com/wiki/#History_ticks/Last_tick


 
 Post subject: Re: How to set stop-loss and take-profit as a function of current spread Post rating: 0   New post Posted: Mon 22 Oct, 2012, 14:04 

User rating: 0
Joined: Tue 16 Oct, 2012, 12:23
Posts: 40
On this page, I saw the following rules for setting stop-loss for an existing order :

https://www.dukascopy.com/wiki/#Set_Stop_Loss_price

In order to set Stop Loss price the following conditions must be met:

- Stop Loss price must be divisible by 0.5 pips, otherwise the order will be rejected.
- One can not set Stop Loss price more than once within a second.

I want to setup stop-loss as a function of spread whose value will be constantly fluctuating. Will these rules come into picture in my case or do they just apply for an existing order?


 
 Post subject: Re: How to set stop-loss and take-profit as a function of current spread Post rating: 0   New post Posted: Wed 24 Oct, 2012, 11:03 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
JimmyHowl8 wrote:
I want to setup stop-loss as a function of spread whose value will be constantly fluctuating. Will these rules come into picture in my case or do they just apply for an existing order?
Yes you have to conform with them.
For rounding sl price to 0.1 pips see:
https://www.dukascopy.com/wiki/#Rounding_prices
For 1 second restriction adhering example see the if condition just after the onTick:
https://www.dukascopy.com/wiki/#Set_Stop_Loss_price/Keep_track_on_Stop_Loss_changes


 

Jump to:  

  © 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