How do I get the commission value in MQL5?

 
Before opening a position for any instrument.

The best I could find - and it was in MQL4 - was AFTER having a position open:

   for (int pos = total - 1; pos >= 0; pos--) {
      if (OrderSelect(pos, SELECT_BY_POS)) {
         posCommission = OrderCommission();
         break;
      }
   }
I'd like to have this info to include in my calculations regarding different instruments before opening a position.

Couldn't find any equivalent in the Market Info in MQL5. Any suggestions?

Thanks in advance.
 
fulljack: Before opening a position for any instrument.

Please search before you post. It is not possible to obtain the commission value before placing and Order, only afterwards.

On MQL5 you can query the deal's properties to obtain the commission cost (after the fact).

HistoryDealGetDouble

Returns the requested property of a deal in the history (double)

ENUM_DEAL_PROPERTY_DOUBLE

DEAL_COMMISSION

Deal commission

double

 

Thanks, Fernando.

I did search, just thought it could have been some evolution in the meantime.

Very sad, as this can be 30-50% of your profit, really impacting the choice of broker and who gets to have your money.

Will keep looking for ways to get around this, but for the time being I guess it'm bound to lean on mostly unreliable recommendations, and keep a jaggy Excel sheet around.

Appreciate your input.

Reason: