函数分别获取多空持仓订单数量。
- int CalculateBuyOrders()//计算机多单的张数
- {
- int buys=0,sells=0;
- for(int i=0;i<OrdersTotal();i++)
- {
- if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
- if(OrderType()==OP_BUY
- &&
- OrderSymbol()==symbol
- &&
- OrderMagicNumber()==iMagic) buys++;
- }
- return(buys);
- }
- int CalculateSellOrders()//计算空单的张数
- {
- int buys=0,sells=0;
- for(int i=0;i<OrdersTotal();i++)
- {
- if(OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==false) break;
- if(OrderType()==OP_SELL
- &&
- OrderSymbol()==symbol
- &&
- OrderMagicNumber()==iMagic) sells++;
- }
- return(sells);
- }
|