Remove SL and TP from orders

Created at 13 Feb 2018, 02:50
How’s your experience with the cTrader Platform?
Your feedback is crucial to cTrader's development. Please take a few seconds to share your opinion and help us improve your trading experience. Thanks!
swingfish's avatar

swingfish

Joined 25.06.2016

Remove SL and TP from orders
13 Feb 2018, 02:50


i have a bot that loops through all positions in order to get the size of them to later create a Hedge trade.

 

i would like to also remove all SL AND TP orders from this positions to make sure they not get triggered once the countertrade is placed.

is there an easy way to do this without compromising the speed? 

maybe place the hedge position first and then loop through again to remove TP and SL? 

 


@swingfish
Replies

PanagiotisCharalampous
13 Feb 2018, 10:02

Hi swingfish,

Did you try it and noticed any performance issues? What you describe is a simple loop therefore not much things can be done from an algorithmic perspective. I would advise you to use  ModifyPositionAsync to modify your TP and SL to improve the speed of execution of your bulk changes.

Best Regards,

Panagiotis


@PanagiotisCharalampous

swingfish
13 Feb 2018, 18:15

yes it can! by simply run the loop twice.

first loop to count the volume (which the algo does already)
place the counter market order (which the algo does already)

and then take all the time in the world to loop again and remove the SL AND TP as time is not essential anymore (which the algo does NOT do currently)

my question was more related to how to do that at all "remove SL and TP" from orders

 

 

 


@swingfish

PanagiotisCharalampous
14 Feb 2018, 10:06

Hi swingfish,

If you want to remove TP and SL from a position, you need to modify it and set the relevant fields to null. See below

 ModifyPosition(position, null, null);

A suggestion to improve your cBot's performance is to keep track of the open volume during position opening and closing so that you can avoid the loop that counts it.

Let me know if this helps you

Best Regards,

Panagiotis


@PanagiotisCharalampous