在MT4中,当需要获取订单的相关信息时,需要先选中订单 ,使用 OrderSelect()函数.
当需要计算当前的订单的开单价格时,可参考如下代码片段.
if(OrderSelect(0, SELECT_BY_POS)==true)
{
Print("open price for the order 10 ",OrderOpenPrice());
Print("Order #",OrderTicket()," profit: ", OrderTakeProfit());
}
else
Print("OrderSelect() returns error - ",GetLastError());
此时我们有一笔开单如下
执行EA时,可以看到我设置的目标盈利价格是1801.18
开单价格是1836.29