Commissions and Swaps - MQL5

 

Hello MQL5 people.

I'm wondering if anyone knows of a way to read to Commissions and Swaps from the terminal, rather than needing to calculate them programatically. I calculate these within my EA at present, but would rather read them off the terminal if this was possible.

Thanks in advance.

 

I have tried using HistoryDealGetDouble(ticket,DEAL_SWAP) and DEAL_COMMISSION but both return a value of zero.

Does anyone have any suggestions?

//get all Deals of Open Position
         HistorySelect(Position_Opentime,TimeCurrent());
         int DealsTotal = HistoryDealsTotal();
         Print("Line#: ",__LINE__," DealsTotal: ",DealsTotal);
         
         Position_Swap    = 0;
         Position_Commission  = 0;
         
         if(PositionStatus == POSITION_BUY)
         {
            for(int i=0; i<=DealsTotal-1; i++)
            {
               ulong Ticket = HistoryDealGetTicket(i);
               Print("Line#: ",__LINE__," Deal #: ",i," Deal Ticket:", Ticket);
               
               if(HistoryDealGetString(Ticket,DEAL_SYMBOL)   == _Symbol
               && HistoryDealGetInteger(Ticket,DEAL_MAGIC)   == MagicNumber
               && HistoryDealGetInteger(Ticket,DEAL_TYPE)    == DEAL_TYPE_BUY)
               {
                  Position_Swap        = Position_Swap       + HistoryDealGetDouble(Ticket,DEAL_SWAP);
                  Position_Commission  = Position_Commission + HistoryDealGetDouble(Ticket,DEAL_COMMISSION);
                  Print("Line#: ",__LINE__," Position_Swap: ",Position_Swap);
                  Print("Line#: ",__LINE__," Position_Commission: ",Position_Commission);

               }
            }
         }   
Reason: