POSITION_COMMISSION missing in Position properties documentation (MT5)

 

How is it that the POSITION_COMMISSION property is not indicated in the documentation on the properties of positions, nor proposed in the code completion in MetaEditor?

https://www.mql5.com/en/docs/constants/tradingconstants/positionproperties#enum_position_property_double

However, we find the property in the list of MQL5 constants


https://www.mql5.com/en/docs/constant_indices

And if we enter PositionGetDouble (POSITION_COMMISSION) in code, it goes with compilation and execution !!!

Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Position Properties
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Position Properties
  • www.mql5.com
Position ticket. Unique number assigned to each newly opened position. It usually matches the ticket of an order used to open the position except when the ticket is changed as a result of service operations on the server, for example, when charging swaps with position re-opening. To find an order used to open a position, apply the...
 
really? 
This works?
 
amando:
really? 
This works?
Yes
 
Laurent Soudron:

How is it that the POSITION_COMMISSION property is not indicated in the documentation on the properties of positions, nor proposed in the code completion in MetaEditor?

https://www.mql5.com/en/docs/constants/tradingconstants/positionproperties#enum_position_property_double

However, we find the property in the list of MQL5 constants


https://www.mql5.com/en/docs/constant_indices

And if we enter PositionGetDouble (POSITION_COMMISSION) in code, it goes with compilation and execution !!!

The commission paid is stored in DEAL_COMMISSION


Following script does not return the commission paid

   ulong ticket;
   int pos_total = PositionsTotal();

   printf("There are %d open positions", pos_total);

   for(int i = 0; i <= pos_total; i++)

      if((ticket = PositionGetTicket(i)) > 0)
        {
         Print("POS: Position Ticket= ",     ticket);
         Print("POS: Position ID= ",         PositionGetInteger(POSITION_IDENTIFIER));
         Print("POS: Date and Time Open= ",  TimeToString(PositionGetInteger(POSITION_TIME),TIME_DATE)," ", TimeToString(PositionGetInteger(POSITION_TIME),TIME_MINUTES));
         Print("POS: Position type= ",       PositionGetInteger(POSITION_TYPE));
         Print("POS: magic= ",               PositionGetInteger(POSITION_MAGIC));
         Print("POS: volume= ",              PositionGetDouble(POSITION_VOLUME));
         Print("POS: price open= ",          PositionGetDouble(POSITION_PRICE_OPEN));
         Print("POS: price current= ",       PositionGetDouble(POSITION_PRICE_CURRENT));
         Print("POS: takeprofit= ",          PositionGetDouble(POSITION_TP));
         Print("POS: stoploss= ",            PositionGetDouble(POSITION_SL));
         Print("POS: swap= ",                PositionGetDouble(POSITION_SWAP));
         Print("POS: profit= ",              PositionGetDouble(POSITION_PROFIT));
         Print("POS: comision= ",            PositionGetDouble(POSITION_COMMISSION));
         Print("============-----------<][>-----------============");
        }
 
Fernando Morales:

The commission paid is stored in DEAL_COMMISSION


Following script does not return the commission paid

You're right Fernando, thank you

Is it intentional by MetaQuotes or is it an error because the keyword can be found in the MT5 constants and the compiler accepts the syntax anyway.

 

The documentation is not up to par, that is for sure.

@Fernando Morales is correct. The commission is in DEAL_COMMISSION this is single trip. For forex round trip commission is in DEAL_ENTRY_IN and DEAL_ENTRY_OUT. They can be different, it is not total commission divided by 2.

Another thing to note is MT5 tester considers a trade profitable  if POSITION_PROFIT + DEAL_ENTRY_OUT DEAL_COMMISSION  is >0. DEAL_ENTRY_IN commission is added to gross loss. This skews tester reports.

 
Thanks for the clarification Enrique
 
Can a moderator see with MetaQuotes and give us feedback please ?
 

i've checked the online documentation, there is no POSITION_COMMISSION, at least not in the german

in the deal everything is right, bus the commission is paid in the deal.

i even tried to test it

void OnStart()
  {
//---
   ulong pos;
   int total = PositionsTotal();

   for(int i=total-1; i>=0; i--)
  {
   pos=PositionGetTicket(i);
      PositionSelectByTicket(pos);

      Print(PositionGetString(POSITION_SYMBOL)," Position: ", pos," Commission: ",PositionGetDouble(POSITION_COMMISSION));

     }

  }

what me wonder, there is no compiler error

but the result of commission is always 0

Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Position Properties
Documentation on MQL5: Constants, Enumerations and Structures / Trade Constants / Position Properties
  • www.mql5.com
Position ticket. Unique number assigned to each newly opened position. It usually matches the ticket of an order used to open the position except when the ticket is changed as a result of service operations on the server, for example, when charging swaps with position re-opening. To find an order used to open a position, apply the...
 

It is for these 2 reasons that I asked the question in the forum.

If it is intended to be managed in the DEAL then it should not be accepted by the compiler and it should not be mentioned in the online documentation in the constants for POSITION !

 

I tried with this code but the commission is still 0 in either case (with DEAL_COMMISSION and POSITION_COMMISSION)

Can you help me please ?

   ulong ticket;   
   int pos_total = PositionsTotal();
   for ( int i = 0; i <= pos_total; i++ )
          if ( (ticket = PositionGetTicket( i )) > 0 ) 
          {
                  Print("POS: Position Ticket= ",                 ticket );
                  Print("POS: Position ID= ",                             PositionGetInteger(POSITION_IDENTIFIER)         );
                  Print("POS: Date and Time Open= ",              TimeToString(PositionGetInteger(POSITION_TIME),TIME_DATE)," ", TimeToString(PositionGetInteger(POSITION_TIME),TIME_MINUTES) );
                  Print("POS: Position type= ",                   PositionGetInteger(POSITION_TYPE)                       );
                  Print("POS: magic= ",                                   PositionGetInteger(POSITION_MAGIC)                      );
                  Print("POS: volume= ",                                  PositionGetDouble(POSITION_VOLUME)                      );
                  Print("POS: price open= ",                              PositionGetDouble(POSITION_PRICE_OPEN)          );
                  Print("POS: price current= ",                   PositionGetDouble(POSITION_PRICE_CURRENT)       );
                  Print("POS: takeprofit= ",                              PositionGetDouble(POSITION_TP)                          );
                  Print("POS: stoploss= ",                                PositionGetDouble(POSITION_SL)                          );
                  Print("POS: swap= ",                                    PositionGetDouble(POSITION_SWAP)                        );
                  Print("POS: profit= ",                                  PositionGetDouble(POSITION_PROFIT)                      );
                  ulong deal_ticket = HistorySelectByPosition(PositionGetInteger(POSITION_IDENTIFIER));
                  Print("POS: comision deal= ",                           HistoryDealGetDouble(deal_ticket, DEAL_COMMISSION)          );
                  Print("POS: comision= ",                                PositionGetDouble(POSITION_COMMISSION)          );
                  Print("============-----------<][>-----------============");
          } 
Reason: