I'm very new to coding and made the following parameters to automate my trading strategy. My stop loss just isn't working and I have no explanation as to why.
Also I think my TP and SL are flipped, but even if flipped the TP works just the SL doesn't. Here's where the script mentions SL and TP. There must be an issue somewhere.
p=input.float(2.0,"Desired Profit %")
sl= input.float(1,"Desired Stop loss %")
TP = strategy.position_avg_price * (1 + (p* 0.01))
SL = strategy.position_avg_price * (1 - (sl* 0.01))
if long
strategy.entry("Long", strategy.long)
if short
strategy.entry("Short", strategy.short)
strategy.exit("Exit", "Long",limit=TP)
strategy.exit("Exit", "Long",limit=SL)
strategy.exit("Exit", "Short",limit=TP)
strategy.exit("Exit", "Short",limit=SL)