我想在 MetaTrader 5 的“专家”窗口中打印每笔已平仓交易的损益...
void OnTrade()
{
HistorySelect(0,TimeCurrent());
int trades_total = HistoryDealsTotal();
ulong ticket=HistoryDealGetTicket(trades_total-1);
long deal_type=HistoryDealGetInteger(ticket,DEAL_ENTRY);
long deal_direction=HistoryDealGetInteger(ticket,DEAL_ENTRY);
if(deal_type == 1)
{
double profit=HistoryDealGetDouble(ticket,DEAL_PROFIT);
Print("Ticket ",ticket," Profit: ",profit," Direction: ",deal_direction);
}
} //END OnTrade()
...但是我得到的不仅仅是一个,而是五个(相同的)结果:
我需要在我的代码中进行哪些更改才能只获得一行?
提前谢谢了!