Trade history MQL4 vs MQl5 New comment bodojan468 2021.01.03 21:42 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 mql4 function to turn on and off autotrading how to change indicator's code from Mql4 to Mql5 OrderType() Functionality in MQL5 New comment
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