Hi need help on my code I don't know why my stop loss on short position is not triggering when the price level reached
Can anyone explain me why and help me to fix it `
//short position
var float ssellPrice = 0
ssellCondition = close < s1 and close < s2 and co and strategy.position_size == 0 and f_datefilter
sbuyCondition = close > s2 and co and strategy.position_size < 0 and (not i_higherclose or close > high[1])
sstopDistance = strategy.position_size < 0 ? ((ssellPrice + close) / close) : na
sstopPrice = strategy.position_size < 0 ? ssellPrice + (ssellPrice * sstoppercent) : na
sstopCondition = strategy.position_size < 0 and sstopDistance < sstoppercent
//enter short positions
if ssellCondition
strategy.entry(id="short", direction = strategy.short, comment = "ENTER-SHORT")
if ssellCondition[1]
ssellPrice := open
//exit short position
if sbuyCondition or sstopCondition
strategy.close(id="short", comment="EXIT-SHORT" + (sstopCondition ? "SL=true" : ""))
ssellPrice := na
`
I just need help on my code to trigger those stop loss