This is how get the commission of a position. Do a select with PositionSelect(), PositionSelectByIndex(), PositionGetSymbol() or PositionGetTicket() before using this code.
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'.
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.
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
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; }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'.
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.