Hello everyone,
I'm trying to convert some part of my MQL4 code to MQL5 code.
After reading the documentation, I still have trouble understanding some things. Can you tell if the following code do the same things
MQL4 version:
void historyMQL4(){ for(int z=OrdersHistoryTotal(); z>= 0; z--) { if(OrderSelect(z,SELECT_BY_POS,MODE_HISTORY)){ double op = OrderProfit(); datetime oct = OrderCloseTime(); double oop = OrderOpenPrice(); double otp = OrderTakeProfit(); double osl = OrderStopLoss(); int ot = OrderType(); string os = OrderSymbol(); double ol = OrderLots(); // next code } } } }
MQL5 version
void historyMQL5() { if (HistorySelect(0, INT_MAX)) { int total=HistoryDealsTotal(); for (int i = total - 1; i >= 0; i--) { ulong Ticket = HistoryDealGetTicket(i); if (HistoryDealGetInteger(Ticket, DEAL_ENTRY) == DEAL_ENTRY_OUT) { double op = HistoryDealGetDouble(dticket,DEAL_PROFIT); datetime oct= (datetime)HistoryDealGetInteger(Ticket, DEAL_TIME); double oop = HistoryDealGetDouble(Ticket, DEAL_PRICE); int ot = HistoryDealGetInteger(Ticket, DEAL_TYPE) == DEAL_TYPE_BUY ? DEAL_TYPE_SELL : DEAL_TYPE_BUY; string os = HistoryDealGetString(Ticket, DEAL_SYMBOL); double ol = HistoryDealGetDouble(Ticket,DEAL_VOLUME); const ulong OrderTicket = HistoryDealGetInteger(Ticket, DEAL_ORDER); if (OpenTicket > 0) { double oop = HistoryOrderGetDouble(OrderTicket, ORDER_PRICE_OPEN); double osl = HistoryOrderGetDouble(deal_order, ORDER_SL); double otp = HistoryOrderGetDouble(deal_order, ORDER_TP); } else continue; } // next code } } }
I don't want to use a library? I want to do it with native MQL5.
Happy new year
cheers
You agree to website policy and terms of use
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.
Hello everyone,
I'm trying to convert some part of my MQL4 code to MQL5 code.
After reading the documentation, I still have trouble understanding some things. Can you tell if the following code do the same things
MQL4 version:
MQL5 version
I don't want to use a library? I want to do it with native MQL5.
Happy new year
cheers