获取最近一张持仓多单的开仓价、开仓时间及手数的函数如下:
- 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();
- }
- }
|