获取最近一张持仓订单的开仓价、开仓时间及手数
获取最近一张持仓多单的开仓价、开仓时间及手数的函数如下:double buyop=0;
double buylastlot=0;
int buyOpenTime=0;
for(int i=0; i<OrdersTotal(); i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)&& OrderSymbol()==Symbol() && OrderType() == OP_BUY &&
(OrderMagicNumber()==twobuymagic || OrderMagicNumber()==buymagic))
{
buyop=OrderOpenPrice();
buylastlot=OrderLots();
buyOpenTime=OrderOpenTime();
}
}获取最近一张持仓空单的开仓价、开仓时间及手数的函数如下:
double sellop=0;
double selllastlot=0;
int sellOpenTime=0;
for(i=0; i<OrdersTotal(); i++)
{
if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)&& OrderSymbol()==Symbol() && OrderType() == OP_SELL &&
(OrderMagicNumber()==twosellmagic || OrderMagicNumber()==sellmagic))
{
sellop=OrderOpenPrice();
selllastlot=OrderLots();
sellOpenTime=OrderOpenTime();
}
}
页:
[1]