Read historical orders in MT5

MQL5 Conversão

Trabalho concluído

Tempo de execução 2 horas
Comentário do cliente
good work as always :)

Termos de Referência

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

Respondido

1
Desenvolvedor 1
Classificação
(361)
Projetos
630
72%
Arbitragem
14
43% / 7%
Expirado
28
4%
Livre
Publicou: 9 códigos
2
Desenvolvedor 2
Classificação
(5)
Projetos
5
0%
Arbitragem
5
0% / 60%
Expirado
2
40%
Livre
3
Desenvolvedor 3
Classificação
Projetos
0
0%
Arbitragem
1
0% / 0%
Expirado
0
Livre
4
Desenvolvedor 4
Classificação
(28)
Projetos
36
17%
Arbitragem
5
20% / 40%
Expirado
17
47%
Livre
Publicou: 5 códigos
5
Desenvolvedor 5
Classificação
(64)
Projetos
144
46%
Arbitragem
21
38% / 24%
Expirado
32
22%
Trabalhando
6
Desenvolvedor 6
Classificação
(229)
Projetos
339
49%
Arbitragem
21
5% / 33%
Expirado
24
7%
Livre
7
Desenvolvedor 7
Classificação
(32)
Projetos
41
68%
Arbitragem
5
0% / 60%
Expirado
14
34%
Livre
Publicou: 1 código

Informações sobre o projeto

Orçamento
30+ USD
Prazo
de 1 para 2 dias