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.

Change stopLoss and takeProfit simultaneously?
 Post subject: Change stopLoss and takeProfit simultaneously? Post rating: 0   New post Posted: Fri 24 Jan, 2014, 18:49 
User avatar

User rating: 98
Joined: Mon 23 Jul, 2012, 02:02
Posts: 656
Location: United States, Durham, NC
Concerning the mandatory delay of 1 second between
changes to an Order...

Just checking, assuming an active order/position in
IOrder.State.FILLED...

Is it possible to change both the StopLoss and the TakeProfit
price simultaneously (in quick succession) without the
mandatory 1 second delay, or...

Must we change Stop Loss, for example, and then wait
1 second before changing the Take Profit level ?

It would be nice to have an "atomic" call in IOrder like
IOrder.setStopLossAndTakeProfit(double stopLossPrice, double takeProfitPrice)
which would be "atomic" and not require any delay.

Even better... I would like to see a "batch" or "transaction"
capability, for example:

// this code would not be reliable, due to
// possible exceptions preventing endBatch from executing
order.startBatch();
order.setStopLossPrice(...);
order.setTakeProfitPrice(...);
order.endBatch(); // order change(s) sent to server


In practice you would have to use a try/catch/finally to ensure
that this works reliably, as in pseudocode:
// this format would ensure that endBatch is called
// even with exceptions
try {
    order.startBatch();
    // change one or more order properties
    // which could result in exceptions
    order.setStopLossPrice(...);
    order.setTakeProfitPrice(...);
}
catch(Exception e) {
    // report exception
}
finally {
    order.endBatch(); // ensure endBatch is called
}


Thanks,
HyperScalper


 
 Post subject: Re: Change stopLoss and takeProfit simultaneously? Post rating: 1   New post Posted: Sat 25 Jan, 2014, 10:02 
User avatar

User rating: 96
Joined: Mon 09 Sep, 2013, 07:09
Posts: 287
Location: Ukraine, SHostka
hyperscalper wrote:
Is it possible to change both the StopLoss and the TakeProfit
price simultaneously (in quick succession) without the
mandatory 1 second delay ...?
Yes, it is.


 
 Post subject: Re: Change stopLoss and takeProfit simultaneously? Post rating: 0   New post Posted: Mon 27 Jan, 2014, 08:35 
User avatar

User rating:
Joined: Fri 31 Aug, 2007, 09:17
Posts: 6139
hebasto wrote:
hyperscalper wrote:
Is it possible to change both the StopLoss and the TakeProfit
price simultaneously (in quick succession) without the
mandatory 1 second delay, or...

Yes, it is.
Exactly, because the restriction is per order per operation.


 

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