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 일