0
votes

I was wondering someone could help shed some light on where i am going wrong with the below strategy.exit functions. I have been going round and around in circle messing up the code further and starting again trying to get it to work correctly.

strategy.exit(id="TrailingStop", qty_percent = 100, stop=stopprice, alert_message = close_cmd)

strategy.exit(id="TP", limit=tp, qty_percent = 50, comment= "50%", alert_message = tp_cmd)

I have 2 exits, 1 trailing stop for 100% of position and one take profit/ limit for 50%

it seems due to the order i can only get one to work and not the other. if i stack the trailing stop first then it closes 100% but the take profit is lost but if i code the TP first then the stoploss only closes 50% of the trade is there a way to write them both in the same strategy.exit function while keeping the different %s and alert messages? or a way to code a trailing stop as a strategy.close instruction?

there must be a way to write a trailing stop for 100% and a limit order at 50%?

1

1 Answers

0
votes

try this

strategy.exit(id="TP", limit=tp, qty_percent = 50, comment= "50%", alert_message = tp_cmd)
strategy.exit(id="TrailingStop", qty_percent = 100, limit=tp, stop=stopprice, alert_message = close_cmd)