vovanchau27: My code below calculate average price in MQL4 and it run ok on mt4, How to re-write it in MQL5.
for(int i = OrdersTotal() - 1; i >= 0; i--)
In MT5, orders are pending, positions are open. Rewrite your code to use positions.
Position vs. Deal vs. Order - General - MQL5 programming forum (2019)
Difference between a deal and a trade? - General - MQL5 programming forum (2019)
William Roeder #:
yes, i know position, but i can not find how to get commission of opening order.In MT5, orders are pending, positions are open. Rewrite your code to use positions.
Position vs. Deal vs. Order - General - MQL5 programming forum (2019)
Difference between a deal and a trade? - General - MQL5 programming forum (2019)
//MQL4
double _profit = OrderProfit() + OrderSwap() + OrderCommission();
// ->> MQL5
double _profit = PositionGetDouble(POSITION_PROFIT) + PositionGetDouble(POSITION_SWAP) + commission;
how to get Order Commission?

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
My code below calculate average price in MQL4 and it run ok on mt4, How to re-write it in MQL5.