Discussion of article "Library for easy and quick development of MetaTrader programs (part V): Classes and collection of trading events, sending events to the program" - page 2

 
Alvaro Arioni:

Please edit your post and

use the code button (Alt+S) when pasting code

 
Artyom Trishkin:

There may be more than one lost order

OK, but the function is still returning just one of the lost orders, that which is closest to zero.

In this case, wouldn’t be the same iterating from 0 to start-1 with a break?


ulong CHistoryCollection::OrderSearch(const int start,ENUM_ORDER_TYPE &order_type) 
  { 
   ulong order_ticket=0; 
   for(int i=0; i < start ;i++) 
     { 
      ulong ticket=::HistoryOrderGetTicket(i); 
      if(ticket==0) 
         continue; 
      ENUM_ORDER_TYPE type=(ENUM_ORDER_TYPE)::HistoryOrderGetInteger(ticket,ORDER_TYPE); 
      if(this.IsPresentOrderInList(ticket,type)) 
         continue; 
      order_ticket=ticket; 
      order_type=type; 
      break; 
     } 
   return order_ticket; 
  } 

I know that it is just a detail, but I thought this could be a little improvement, especially in case of a too big history of orders.

Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
Documentation on MQL5: Constants, Enumerations and Structures / Named Constants / Predefined Macro Substitutions
  • www.mql5.com
//| Expert initialization function                                   | //| Expert deinitialization function                                 | //| Expert tick function                                             | //| test1                                                            |...
 
Alvaro Arioni :

OK, but the function is still returning just one of the lost orders, that which is closest to zero.

In this case, wouldn’t be the same iterating from 0 to start-1 with a break?


I know that it is just a detail, but I thought this could be a little improvement, especially in case of a too big history of orders.

Ok, thanks, I'll check and test everything.

It may well be that "break" will come in handy.