工作已完成
![](https://c.mql5.com/i/avatar/avatar_na2.png)
指定
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