History Profit in MQL5 ?
How can I get History Profit in MQL5 ?
This is MT4 code...
Have any example ? Thank you.
- MQL5
double Profit( void ) { double Res = 0; if (HistorySelect(0, INT_MAX)) for (int i = HistoryDealsTotal() - 1; i >= 0; i--) { const ulong Ticket = HistoryDealGetTicket(i); if((HistoryDealGetInteger(Ticket, DEAL_MAGIC) == MagicNumber) && (HistoryDealGetString(Ticket, DEAL_SYMBOL) == Symbol())) Res += HistoryDealGetDouble(Ticket, DEAL_PROFIT); } return(Res); }
- MQL5 + MQL4
#include <MT4Orders.mqh> // https://www.mql5.com/ru/code/16006 double Profit( void ) { double Res = 0; for (int i = OrdersHistoryTotal() - 1; i >= 0; i--) if(OrderSelect(i, SELECT_BY_POS, MODE_HISTORY) && (OrderMagicNumber() == MagicNumber) && (OrderSymbol() == Symbol())) Res += OrderProfit(); return(Res); }
How can I get History Profit in MQL5 ?
This is MT4 code...
Have any example ? Thank you.
HistoryPositionInfo version 2:
The CHistoryPositionInfo class is designed for getting the profit of a position in points, commission, swap and profit in money based on the trading history.
- MQL5
- MQL5 + MQL4
wow! Thanks a lot.
The MQL5 + MQL4 were very cool.
How can I get History Profit in MQL5 ?
This is MT4 code...
Have any example ? Thank you.