Stop loss based on Entry candle high or low — Tradetron Community
← Community

Stop loss based on Entry candle high or low

Strategy 5,157 views

Chirag Gada

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

puneet

Hello Chirag

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

Chirag Gada

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.

JAI

Any update for this question, looking for same solution.

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

mankerajedra

This can be achieved now by using Runtime Variables

Chirag Gada

can you help how can I define that?

Shailesh Bind

can u explain plz how to use runtime variable

Abhijit Bhattacherjee

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.

kali_om

Can you pls explain in detail

Rudresh

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

Tradetron Team Tradetron team

Use runtime variables to store the signal candle’s high and low when the trade is taken (replies #8–#10 are on the right track).

  1. In the entry block’s Runtime section, add:
    • sl_high = Position(HIGH(<symbol, 5m>), -1)
    • sl_low = Position(LOW(<symbol, 5m>), -1)
      -1 is the last closed candle before entry, which is the candle you described.
  2. These are written once, right after the entry leg is taken, so they do not move later.
  3. Set Exit, long trade: LTP(<symbol>) < Get Runtime Number(sl_low). Short trade: LTP(<symbol>) > Get Runtime Number(sl_high).
  4. Use separate sets for long and short, each with its own variables.

Check the stored values from the deployment’s ⋮ menu → Runtime Data. Worked example: Use Entry Candle - High and Low using Runtime Variable - #8 by Nelson

:sparkles: Answer written with AI from Tradetron docs (Oct 2026). Original replies are kept above. Spot something wrong? Reply below.