Stop loss based on Entry candle high or low

I am looking to create a strategy in which when certain conditions are met, a trade is taken either in buy or sell side. I want to set stoploss as signal’s previous candle’s low or high depending on whether it is buy or sell trade. I tried searching the forums but have had no luck in deploying this. Can someone please help me?

Ex.:
Time frame: 5 mins
if sell signal is initiated in between 9:50-9:55 candle, the stoploss should be high of 9:45-9:50 candle.
Similarly, if sell signal is initiated between 10:25-10:30 candle, the stoploss should be high of 10:20-10:25 candle

Hello Chirag

if the entry candle time is known then ORB with the previous time high and low can be used as stoploss

The problem with ORB is that the time for ORB range will be fixed. My trade can get initiated anytime during the day and its SL will be entry candle’s previous candle high or low.

Any update for this question, looking for same solution.

Need to place exit based on EntryTime candle High or Low based on Long/Short

This can be achieved now by using Runtime Variables

can you help how can I define that?

can u explain plz how to use runtime variable

Under runtime, use traded instrument to capture high and low value of that candle. So there will be 2 variable. In your exit condition, you use those variable.

Can you pls explain in detail

When you take the position, create 2 runtime labels. One for high and other for low. Use position keyword with 5 min time frame and store the -1 candle high and low values