I'm creating a strategy with the following code, and whilst manually verifying the orders I have encountered a couple of instances where the strategy.exit() function is not executed when the Take Profit (limit) target is reached, despite there being a candle on the chart where price has wicked past the 2% take profit target
See screenshot 1 where there were 2 candles that wicked past the TP target, but the strategy did not exit.
I've noticed this only a few times, mostly the order is executed (see screenshot 2)
Is there a genuine reason for this, a defect in my code, or a bug on trading views side?
OWRTPLong = strategy.position_avg_price * (1 + (2/100)) //2% above entry price
OWRTPShort = strategy.position_avg_price * (1 - (2/100)) //2% below entry price
//Enter Long Position
if analysisType == "Obtain Win Rate" and ta.crossover(line1, 99)
strategy.order("OWR Long", strategy.long, comment = "Enter Long")
//Take first profits on Long Position
if strategy.position_size > 0
strategy.exit("Long Exit", from_entry = "OWR Long", limit = OWRTPLong, comment = "Exit Long")
//Close Long Position
if analysisType == "Obtain Win Rate" and (ta.crossover(line2, 99) or ta.crossunder(line1, 1))
strategy.close("OWR Long", comment="Close Long")
//---