This can be achieved using a for loop and the OrdersTotal function. In the loop increment a variable with OrderCommission function. Exit when done.

OrderCommission - Trade Functions - MQL4 Reference
- docs.mql4.com
OrderCommission - Trade Functions - MQL4 Reference
Do not count on OrderCommission/OrderSwap. Some brokers don't use
those fields.
please help: Mt4 commission - Trading 4Accounts - MQL4 4and 4MetaTrader 44 - MQL4 4programming 4forum
please help: Mt4 commission - Trading 4Accounts - MQL4 4and 4MetaTrader 44 - MQL4 4programming 4forum
Sorry forget to mention - MT5
Chee Chua:
Sorry forget to mention - MT5
Sorry forget to mention - MT5
#include <MT4Orders.mqh> // https://www.mql5.com/en/code/16006 double TotalCommission() { double Sum = 0; for (int i = OrdersTotal() - 1; i >= 0; i--) if (OrderSelect(i, SELECT_BY_POS)) Sum += OrderCommission(); return(Sum); }

You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
How do I get the total commissions of multiple open positions?
How do I go through all the open positions and adding them up?
Thanks!