POSITION_COMMISSION-property removed!? - page 2

 

This is how get the commission of a position. Do a select with PositionSelect(), PositionSelectByIndex(), PositionGetSymbol() or PositionGetTicket() before using this code.

double PositionGetCommission()
  {
   double commission = 0;
   ulong ticket;
   if(HistorySelectByPosition(PositionGetInteger(POSITION_IDENTIFIER)))
     {
      for(int k = 0; k < HistoryDealsTotal(); k++)
        {
         if((ticket = HistoryDealGetTicket(k)) != 0 && HistoryDealGetInteger(ticket, DEAL_ENTRY) == DEAL_ENTRY_IN)
           {
            commission += HistoryDealGetDouble(ticket, DEAL_COMMISSION);
           }
        }
     }
   return commission;
  }

 
Andreas Hoogendoorn # :

This is how get the commission of a position. D o a select with PositionSelect(), PositionSelectByIndex(),  PositionGetSymbol() or PositionGetTicket() before using this code.


Please note that commission is sometimes charged for both 'DEAL_ENTRY_IN' and 'DEAL_ENTRY_OUT'.

 
Vladimir Karputov #:

Please note that commission is sometimes charged for both 'DEAL_ENTRY_IN' and 'DEAL_ENTRY_OUT'.

It is hard to know what the total commission will be when a positions is still open. Therefor I have chosen to not include the DEAL_ENTRY_OUT. With this code we get the entry-commission (not included partially closed positions). Multiply by 2 to get the (future) total commission.

 
A position never have commission, only deals have
Reason: