Pending order (with 2-bar expiry) triggered, but not expired (while others before it do expire)

 

Greetings,


I am struggling to figure out what's happening in this case. Scenario:

  • MQL5 EA
  • Pending buy order with expiry (2 bars) is placed successfully (like many others before it during a back-test which work just fine, ie, expiries work, see history image below)
  • The pending order is triggered appropriately and a position is opened
  • For reasons unknown, this particular position never expires - it just stays open consuming margin (then the test period ends)
  • Tried back-testing with 'Every tick' and 'Every tick based on real ticks'
  • History quality is 100%

Here's the journal:

This is on the 15M TF, so there are many bars from when the position is opened and the day closes, so ample opportunity to 'expire' the trade, but it just doesn't happen.


Here's the History:


And here's the operations:


Any ideas on what the reason for this could be? 

Wondering if there's something else I can check/examine to figure out why this is happening.

Thanks


Edit to add the code:

if(!trade.BuyLimit(NormalizeDouble(lots, 2), price, _Symbol, sl, tp, ORDER_TIME_SPECIFIED, expiry, EAComment)) {
    Print("ERROR: Failed to place Buy Limit order: ", trade.ResultRetcode(), " - ", trade.ResultRetcodeDescription());
}

To emphasize, many pending orders are placed successfully, including the one in question, using the above code, so I know it works.