#include <MT4Orders.mqh> // https://www.mql5.com/en/code/16006 double profit = 0.0; for (int i=0; i<OrdersHistoryTotal(); i++) { if(OrderSelect(i, SELECT_BY_POS, MODE_HISTORY)) { int orderTicket = (int)OrderTicket(); string orderSymbol = OrderSymbol(); int orderType = (int) OrderType(); if(orderType == 0) { profit = profit + OrderProfit(); } } }Now it will work on MQL5.
fxsaber:
Now it will work on MQL5.
Now it will work on MQL5.
Looks quite convenient though.
Thanks for your link.
Transferring Indicators from MQL4 to MQL5
- 2010.07.28
- Vasily
- www.mql5.com
This article is dedicated to peculiarities of transferring price constructions written in MQL4 to MQL5. To make the process of transferring indicator calculations from MQL4 to MQL5 easier, the mql4_2_mql5.mqh library of functions is suggested. Its usage is described on the basis of transferring of the MACD, Stochastic and RSI indicators.
MQL5 Wizard generates Expert Advisers for MetaTrader 4
- 2017.02.21
- Stanislav Korotky
- www.mql5.com
As you all already know, both MetaTrader 4 and MetaTrader 5 provide MQL Wizard for easy code generation. Between these 2 wizards there is one important difference though. MetaTrader 5 allows you to...
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
Dear Coder
Since the migrants to MQL5 language, there are many differences in the coding structure to work with historical trades in mql5 language.
Here I would like to discuss any problem related to Historical Trades.
I just simply feel this is necessary because the History Deal structure from MQL5 language is quite confusing.
I am little scared to use it because some simple works in mql4 seems not straight forwards any more in mql5.
For example, I want find out the profit for buy trades.
In MQL4, this can be done like this. Profit for sell trades can be done easily just changing orderType == 1.
In mql5 language, it seems even difficult to deal with this simple task.
What is the best way to safely get profit for buy or sell trades only ?
I can think of something like this. But there is too much risk of using HistoryDealGetInteger structure.
Because there are chances, DEAL_ENTRY can be DEA_ENTRY_INOUT or DEAL_ENTRY_OUYBY, etc.
Plus orderType is also opposite in mql5.com ?
What would be developer's mind to migrate the absolutely easy historical trades structure mql4 language to something less safe and more difficult to use.
I am really curious on this.
Sharing your thought on this issue will be really appreciated.
Kind regards.