|
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.
Cancelling Stop Loss/Profit Target Orders Does Closeout |
[adamant]
|
Post subject: Cancelling Stop Loss/Profit Target Orders Does Closeout |
Post rating: 0
|
Posted: Tue 27 Jan, 2009, 01:45
|
|
User rating: 0
Joined: Mon 15 Dec, 2008, 16:59 Posts: 11
|
Hello,
I think I have found a nasty bug with cancelling stop loss/profit targets orders.
I submit an order through JForex including a stop loss and profit target and 3 orders are created as expected.
If the main order then gets filled, the stop loss/profit target then become active.
I then decide to create an opposite order to closeout my main position before it reaches the stop loss/profit targets.
I now have a flat position, but the 2 stop loss/profit target orders still exist.
When I then cancel these unwanted orders using order.close() (i don't think there is an explicit order.cancel()), rather than cancelling them JForex closes them out by filling prices from the market twice in opposite directions with 2 comission charges!
Please can you tell me whether this is expected behaviour, and how to cancel the orphaned stop loss/profit target orders without going to the market.
Thanks
|
|
|
|
 |
[adamant]
|
Post subject: Re: Cancelling Stop Loss/Profit Target Orders Does Closeout |
Post rating: 0
|
Posted: Tue 27 Jan, 2009, 01:47
|
|
User rating: 0
Joined: Mon 15 Dec, 2008, 16:59 Posts: 11
|
I forgot to mention that the stop loss and profit target orders are also set to order status FILLED once their parent order is flat, rather than OPENED or CREATED.
Ideally these two orders would cancel themselves when the original position becomes flat.
|
|
|
|
 |
API Support
|
Post subject: Re: Cancelling Stop Loss/Profit Target Orders Does Closeout |
Post rating: 0
|
Posted: Tue 27 Jan, 2009, 09:38
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
Hi, In jForex API we don't separate take profit/stop loss orders in different orders. All the three orders are only one order in jForex. To cancel TP/SL orders you don't need to call order.close() because it will close main order, but you need to call setTakeProfitPrice(0) and setStopLossPrice(0).
|
|
|
|
 |
AbsoluteReturner
|
Post subject: Re: Cancelling Stop Loss/Profit Target Orders Does Closeout |
Post rating: 0
|
Posted: Mon 05 Sep, 2011, 16:13
|
|
User rating: 1
Joined: Tue 12 Jul, 2011, 20:43 Posts: 51 Location: Germany,
|
Hi support,
can you please provide a code fragment which shows how to early close correctly an order created with TakeProfit and StopLoss ? Assuming order is filled (means position is open) and I want to close position and also delete TP and SL immediately. Do I have to call setTakeProfitPrice(0) and setStopLossPrice(0) and then close(order) only, or is it necessary to insert any WaitForUpdate() statement between, or are there any other issues to be considered ?
Regards AbsoluteReturner
|
|
|
|
 |
API Support
|
Post subject: Re: Cancelling Stop Loss/Profit Target Orders Does Closeout |
Post rating: 0
|
Posted: Tue 06 Sep, 2011, 09:44
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
AbsoluteReturner wrote: Assuming order is filled (means position is open) and I want to close position and also delete TP and SL immediately. Do I have to call setTakeProfitPrice(0) and setStopLossPrice(0) and then close(order) only, or is it necessary to insert any WaitForUpdate() statement between, or are there any other issues to be considered ? Both TP and SL orders get cancelled upon calling IOrder.close(), meaning that JForex platform handles this for you. See more here: https://www.dukascopy.com/wiki/index.php ... Loss_price
|
|
|
|
 |
AbsoluteReturner
|
Post subject: Re: Cancelling Stop Loss/Profit Target Orders Does Closeout |
Post rating: 0
|
Posted: Wed 07 Sep, 2011, 09:55
|
|
User rating: 1
Joined: Tue 12 Jul, 2011, 20:43 Posts: 51 Location: Germany,
|
Sorry, but I'm still unsure how to close an order including SL and TP. On Tue 27 Jan, 2009, 09:38 you wrote: Quote: To cancel TP/SL orders you don't need to call order.close() because it will close main order, but you need to call setTakeProfitPrice(0) and setStopLossPrice(0). As I understand this statement is in opposition to your last posting - can you please clarify this ? Regards AR
|
|
|
|
 |
API Support
|
Post subject: Re: Cancelling Stop Loss/Profit Target Orders Does Closeout |
Post rating: 0
|
Posted: Wed 07 Sep, 2011, 12:07
|
|
User rating: ∞
Joined: Fri 31 Aug, 2007, 09:17 Posts: 6139
|
AbsoluteReturner wrote: Api Support wrote: To cancel TP/SL orders you don't need to call order.close() because it will close main order, but you need to call setTakeProfitPrice(0) and setStopLossPrice(0).
As I understand this statement is in opposition to your last posting - can you please clarify this ? No, the two don't contradict. The statement says that if you only want to close Stop Loss without closing the main order, then you should use IOrder.setStopLossPrice(0). However, the last post says that if you want to close the main order with its Stop Loss then just use IOrder.close() and you don't have to call IOrder.setStopLossPrice(0).
|
|
|
|
 |
AbsoluteReturner
|
Post subject: Re: Cancelling Stop Loss/Profit Target Orders Does Closeout |
Post rating: 0
|
Posted: Wed 07 Sep, 2011, 12:21
|
|
User rating: 1
Joined: Tue 12 Jul, 2011, 20:43 Posts: 51 Location: Germany,
|
It is clear now, thanks !
Regards AR
|
|
|
|
 |
|
Pages: [
1
]
|
|
|
|
|