Page 1 of 1

Does this exist?

Posted: Thu Sep 21, 2023 8:08 pm
by richmusic
Does anyone know of a script or how to script a way to have Tradingview move the stoploss automatically to break even after price reaches a certain level? I don't want a trailing stop, I just want something that will move the stop to break even after it reachers a certain point. Does that exist, or can someone write the script, or do you know if that's possible? I'm very new to all of this programming. Thank you.

Re: Does this exist?

Posted: Tue Sep 26, 2023 11:47 pm
by Steve Burman
To set the SL to break even simply update the stop value to the entry price of the trade when the RR ratio is met.

e.g. if you had an strategy.exit statement as strategy.exit(id="Long Exit", from_entry="Long", limit=t_target, stop=t_stop) then you save the entry price in a variable when your strateg.entry function is run then set your t_stop variable to that entry price so the next time the strategy.exit statement is read it will be setting the stop as the entry price (break even)