How to make stop loss in pine script strategy?

Viewed 23

When take profit worked i need to close 50% of my qty but when stop loss worked i need to close all my position. My code:

strategy.exit("long profit", "long", limit = take, qty_percent=50)
strategy.exit("long stop", "long", stop = stop)

And i am getting result like there

1 Answers

You have two exit orders but only one of them have the stop loss value set. Instead, all of them should have the stop argument.

strategy.exit("long profit", "long", limit = take, stop=stop, qty_percent=50)
strategy.exit("long stop", "long", stop = stop)
Related