Read historical orders in MT5

MQL5 Converting

Job finished

Execution time 2 hours
Feedback from customer
good work as always :)

Specification

hi,


i need this function migrated MT5:


string getLastHistTradeString(){


   bool seperator = false;

   int acc = AccountNumber();

   string broker = AccountCompany();

   double balance = AccountBalance();

   

   

   string histTrades = "";

   for(int i=0 ; i <OrdersHistoryTotal() ; i++)

      {  

      

         OrderSelect(i, SELECT_BY_POS,MODE_HISTORY);

      

         if(OrderOpenTime() > lastDeliveredHistTrade)

         {

            

            

            int orderNumber = OrderTicket();

            datetime openTime = OrderOpenTime();

            int orderType = OrderType();

            double lots = OrderLots();

            string symbol = OrderSymbol();

            double openPrice = OrderOpenPrice();

            double sl = OrderStopLoss();

            double tp = OrderTakeProfit();

            datetime closeTime = OrderCloseTime();

            double closePrice = OrderClosePrice();

            double commision = OrderCommission();

            double swap = OrderSwap();

            double profit = OrderProfit();

            double equity = AccountEquity();

            double accountBalane = AccountBalance();

            

            string jsonString = "{\"accountNumber\": " + acc + ", "+

                                 "\"broker\": \"" + broker + "\", "+

                                 "\"orderNumber\": " + orderNumber + ", "+

                                 "\"orderOpenTime\": \"" + openTime + "\", "+

                                 "\"orderType\": " + orderType + ", "+

                                 "\"orderLots\": " + lots + ", "+

                                 "\"orderSymbol\": \"" + symbol + "\", "+

                                 "\"orderOpenPrice\": " + openPrice + ", "+

                                 "\"orderStopLoss\": " + sl + ", "+

                                 "\"orderTakeProfit\": " + tp + ", "+

                                 "\"orderCloseTime\": \"" + closeTime + "\", "+

                                 "\"orderClosePrice\": " + closePrice + ", "+

                                 "\"orderCommission\": " + commision + ", "+

                                 "\"orderSwap\": " + swap + ", "+

                                 "\"orderProfit\": " + profit + ", "+

                                 "\"accountBalance\": " + accountBalane + ", "+

                                 "\"accountEquity\": " + equity +

                                 "}";

           if(seperator){

            histTrades += ",";

           }

           

           histTrades += jsonString;

           seperator = true;

         }        

       }

       

       string finalString = "["+histTrades+"]";

       

       printf(finalString);

       

       return finalString;

   


}


it should read all historic trades and put it into a json string


you will give me the source code for it


thanks

Responded

1
Developer 1
Rating
(360)
Projects
624
72%
Arbitration
14
43% / 7%
Overdue
28
4%
Free
Published: 9 codes
2
Developer 2
Rating
(5)
Projects
5
0%
Arbitration
5
0% / 60%
Overdue
2
40%
Free
3
Developer 3
Rating
Projects
0
0%
Arbitration
1
0% / 0%
Overdue
0
Free
4
Developer 4
Rating
(28)
Projects
36
17%
Arbitration
5
20% / 40%
Overdue
17
47%
Free
Published: 5 codes
5
Developer 5
Rating
(64)
Projects
144
46%
Arbitration
19
42% / 16%
Overdue
32
22%
Free
6
Developer 6
Rating
(229)
Projects
339
49%
Arbitration
21
5% / 33%
Overdue
24
7%
Free
7
Developer 7
Rating
(32)
Projects
41
68%
Arbitration
5
0% / 60%
Overdue
14
34%
Free
Published: 1 code

Project information

Budget
30+ USD
VAT (19%): 5.7 USD
Total: 35.7 USD
For the developer
27 USD
Deadline
from 1 to 2 day(s)