Read historical orders in MT5

MQL5 转化中

工作已完成

执行时间2 小时
客户反馈
good work as always :)

指定

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

反馈

1
开发者 1
等级
(361)
项目
630
72%
仲裁
14
43% / 7%
逾期
28
4%
空闲
发布者: 9 代码
2
开发者 2
等级
(5)
项目
5
0%
仲裁
5
0% / 60%
逾期
2
40%
空闲
3
开发者 3
等级
项目
0
0%
仲裁
1
0% / 0%
逾期
0
空闲
4
开发者 4
等级
(28)
项目
36
17%
仲裁
5
20% / 40%
逾期
17
47%
空闲
发布者: 5 代码
5
开发者 5
等级
(64)
项目
144
46%
仲裁
21
38% / 24%
逾期
32
22%
工作中
6
开发者 6
等级
(229)
项目
339
49%
仲裁
21
5% / 33%
逾期
24
7%
空闲
7
开发者 7
等级
(32)
项目
41
68%
仲裁
5
0% / 60%
逾期
14
34%
空闲
发布者: 1 代码

项目信息

预算
30+ USD
截止日期
从 1 到 2 天