Is this ok to use this generic function for collecting tickets ?

 
// custom callback for processing deals
typedef bool (*DealProcessor) (ulong ticket);

bool DealProcessor_DEAL_ENTRY_OUT(ulong ticket) {
  return HistoryDealGetInteger(ticket, DEAL_ENTRY) == DEAL_ENTRY_OUT;
}

bool DealProcessor_PROFIT_ANY(ulong ticket) {
  return HistoryDealGetDouble(ticket, DEAL_PROFIT) != 0;
}

// for each deal, call the callback
CArrayLong* ProcessDeals(DealProcessor& handlers[], datetime from, datetime to) {
  HistorySelect(from, to);
  int total = HistoryDealsTotal();
  CArrayLong *arr = new CArrayLong;
  for (int i=0; i<total; i++){
    ulong ticket = HistoryDealGetTicket(i);
    if (ticket > 0 ){
      int handlers_count = ArraySize(handlers);
      int valid_times = 0;
      for (int j=0; j < handlers_count; j++) {
        if (!handlers[j](ticket)) {
          break;
        }
        else {
          valid_times++;
        }
      }
      if (valid_times == handlers_count) {
        arr.Add(ticket);
      }
    }
  }
  return arr;
}


....
      DealProcessor x[2] = {
        DealProcessor_DEAL_ENTRY_OUT, 
        DealProcessor_DEAL_PROFIT_ANY
      };
      CArrayLong deals = ProcessDeals(x, 0, TimeCurrent());
....

Hey i wonder if there's a better way or overall this is bad to do this stuff in such a way? 

 
Your topic has been moved to the section: Expert Advisors and Automated Trading — Please consider which section is most appropriate — https://www.mql5.com/en/forum/172166/page6#comment_49114893
 
ama bamo:

Hey i wonder if there's a better way or overall this is bad to do this stuff in such a way? 

A matter of taste.

 
fxsaber #:

A matter of taste.

Thanks for input, what is your taste on that topic if you mind sharing?

 
ama bamo #:

Thanks for input, what is your taste on that topic if you mind sharing?

I don't collect deal tickets, because... I don’t use writing MT5-programs in MT5-style.