I’ve been trying to fix this issue with my trading script for days now, but I’m stuck. The problem is that when the stop loss is hit, the position doesn’t get closed 100%. Instead, it hits the stop loss, and if the price goes back to TP1, the whole position closes at that point.
I want the position to fully close when the stop loss is hit. Can anyone help me figure out what’s wrong with my code? Here it is:
strategy.entry("Long", strategy.long, qty=position_sizeLong)
if (trailing_Long_ONOFF == "ON")
strategy.exit("Long",loss = stop_loss_in_tickslong,profit = take_profit_in_ticksLong_ATR,trail_price=TraillingActivatedLong ? trailActivationPriceLong : na,trail_offset=TraillingActivatedLong ? trailOffsetTicksLong : na)
if useMultitp
strategy.exit("Long TP1", "Long", qty_percent=30, profit=take_profit_in_ticksLong_ATR/2,comment_profit = "Long TP1")
else
strategy.exit("Long",loss = stop_loss_in_tickslong,qty_percent=100, profit = take_profit_in_ticksLong_ATR)
if useMultitp
strategy.exit("Long TP1", "Long", qty_percent=30, profit=take_profit_in_ticksLong_ATR/2,comment_profit = "Long TP1")