Strategy Tester - Invalid request while closing pending order (MT5)

 

Hello,

I keep getting Invalid Request errors while trying to delete a pending order on the MT5 strategy tester.

Running the EA on live has no issues.


I've paused the EA on a breakpoint to show the issue:

The journal shows this error:


Code:

#include <Trade/Trade.mqh>
#include <MT4Orders.mqh>
#include <MQL4_to_MQL5_Custom.mqh>
#include <CHistoryPositionInfo.mqh>


void OnTick() {
   for(int i = 0; i < ArraySize(closes); i++){
      if(closes[i] != 0){
         if(OrderDelete(closes[i])){
            closes[i] = 0;
         }
      }
   }
}

The closes array contains an item with 10 on it (the ticket number of the trade)

I have also tried deleting it with CTrade, I get the same error.


Any hints?

 
Attach the mq5/mqh-files so others can reproduce the error.
Reason: