Trying to get correct history data in my indicator

 
Hello,
a function of my indicator is to get history data and visualize the information of the History tab of MT5 to make it easier for me. The thing is that after some tries I realized I was getting double the number of positions that I had in the MT5 history tab.  although I was getting the correct  profit. So after checking a bit the Deal Properties I found the deal_entry https://www.mql5.com/en/docs/constants/tradingconstants/dealproperties#enum_deal_entry . So I supposed that I was counting the entry in deal and the entry out. But that information is seen only as 1 in the MT5 history tab. So I decided that I would add all deal profits but only add to the position counter if the entry type was out. The thing is that there are 2 other types which I never use, or I think so, and would like to know if doing what I do will get always a correct answer or is it possible that one deal made by an user could be of the other types and should be added into the counter. Here my code:
void ShowHistory(datetime initialDate){
         SymbolHistoryData shData[];
         ulong ticket=0;
         double totalOrderProfit=0.0;
         double orderProfit=0.0;
         double orderSwap=0.0;
         double orderComission=0.0;
         long orderType=-1;
         HistorySelect(initialDate, TimeCurrent());
         for(int i=0; i<HistoryDealsTotal(); i++){
            ticket=HistoryDealGetTicket(i);
            if(ticket>0){
               orderType=HistoryDealGetInteger(ticket, DEAL_TYPE);
               if(orderType==DEAL_TYPE_BUY || orderType==DEAL_TYPE_SELL){
                  orderProfit=HistoryDealGetDouble(ticket, DEAL_PROFIT);
                  orderSwap=HistoryDealGetDouble(ticket, DEAL_SWAP);
                  orderComission=HistoryDealGetDouble(ticket, DEAL_COMMISSION);
                  totalOrderProfit=orderProfit+orderSwap+orderComission;
                  bool addOrder=HistoryDealGetInteger(ticket, DEAL_ENTRY)==DEAL_ENTRY_OUT;
                  AddHistoryData(shData, HistoryDealGetString(ticket, DEAL_SYMBOL), totalOrderProfit, addOrder);
               }
            }
         }
         for(int i=0; i<ArraySize(shData); i++){
            Print(shData[i].symbolID+" "+shData[i].nOrders+" "+shData[i].profit);
         }
      }
The AddHistoryData just tries to find the symbol position in the array and if it does it updates the profit and add one to the counter if the deal is DEAL_ENTRY_OUT. If it doesn't find it, it just resizes and creates a new symbol in the array. Is it a good practice or should I take into account the oher two types: DEAL_ENTRY_INOUT and DEAL_ENTRY_OUT_BY? My goal is that my counter(shData[i].nOrders) reflects the same number that are shown in the MT5 history tab.

Thank you!
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Deal Properties
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Deal Properties
  • www.mql5.com
A deal is the reflection of the fact of a trade operation execution based on an order that contains a trade request. Each trade is described by...