help with mql5 code, loop closed orders ,if order just closed =alert

 

help with mql5 code, loop closed orders ,if order just closed =alert

i have code for mq4 i want code for Mq5 without MT4Orders.mqh

// Loop through closed orders
for (int i=OrdersHistoryTotal()-1; i>=0; i--)
{
   if (OrderSelect(i, SELECT_BY_POS, MODE_HISTORY))
   {
      // Check if the order was just closed
      if (OrderCloseTime() >= TimeCurrent() - PeriodSeconds(1))
      {
         // Generate an alert
         Alert("Order just closed: Ticket #", OrderTicket(), ", Type: ", OrderType(), ", Lots: ", OrderLots(), ", Profit: ", OrderProfit());
      }
   }
}






...

after all attempt still not working

 

Maybe you can use this: https://www.mql5.com/en/code/16006

to use MT4 orders in MT5.

Beside that here are some articles about migrating from MQL4 to MQL5
https://www.mql5.com/en/articles/81
https://www.mql5.com/en/articles/66
https://www.mql5.com/en/forum/179991 // MT4 => MT5 converter
https://www.mql5.com/en/code/16006  // mt4 orders to mt5
https://www.mql5.com/en/blogs/post/681230
https://www.mql5.com/en/users/iceron/publications => Chosse one of his CrossPlattform articles
MT4Orders
MT4Orders
  • www.mql5.com
Parallel use of the MetaTrader 4 and MetaTrader 5 order systems.