Remove SL and TP from orders

13 Feb 2018, 02:50Remove SL and TP from orders#1
swingfishposts: 34since: 25 Jun 2016

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? 

 

13 Feb 2018, 10:02#2
Panagiotis Charalampousposts: 1200since: 13 Jan 2017

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


Head of Community Management at cTrader
13 Feb 2018, 18:15#3
swingfishposts: 34since: 25 Jun 2016

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

 

 

 

14 Feb 2018, 10:06#4
Panagiotis Charalampousposts: 1200since: 13 Jan 2017

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


Head of Community Management at cTrader