Using the initial image, I think this is what’s happening:
The orders are only evaluated at the end of a bar, which I think here is every 15min, and placed on the next bar.
The 094500-100000 bar updates the HI and LO levels at the open of the bar, and since time is always going forward, the condition for that is true at the end of the bar, so levels are set.
Also, that candle closes below the HI level, since the close is below the high with this candle.
The 100000-101500 bar, opens below HI but wicks up through HI, and here your expecting a order because the trigger condition has been met.
However, the break of HI condition is true while the price is above HI, but then it falls to the close of the bar.
At the end of this bar, the break HI condition is false, so when the order is evaluated, the condition is false, so no order can be made.
The 101500-103000 bar, plays out a similar story as the prior bar, break in the HI level, but below it at the end of the bar, so no order.
The 103000-104500 bar, opens below the HI and then breaks through and closes above HI.
Here the trigger condition is still true at the end of the bar and the order is placed as required at the start of the next bar.
The 104500-110000 bar, note that the order is placed at the right level but its below the close of the prior bar which triggered it.
If the order is a limit order, the price needs to cross the order level from below, but its initially above.
I’m guessing here since the only way to get definitive proof is to look at the ticks, but
when the price falls back below the order level, it probably went back above with the swing of the price and triggered the order in the process.
Since the order was sent to broker, the bar end is not in the equation any more since it was triggered in the bar.
The order is executed the trade continue till the stop level is hit, several bars later with a loss.
If this is all correct, then the problems is the waiting till the end of the bar before order is evaluated.
An initial solution, is to run the code at a lower timeframe for the faster orders but, the hi/lo levels etc at the 15min timeframe, or some combination etc.