统计持仓订单的多空单数量及总数量
函数统计持仓订单的多空单数量及总数量。int CheckOpenPositions()
{
int cnt, total, NumPositions;
int NumBuyTrades, NumSellTrades; // Number of buy and sell trades in this symbol
NumBuyTrades = 0;
NumSellTrades = 0;
total=OrdersTotal();
for(cnt=0;cnt<TOTAL;CNT++)
{
OrderSelect (cnt, SELECT_BY_POS, MODE_TRADES);
if ( OrderSymbol() != Symbol()) continue;
if ( OrderMagicNumber() != MagicNumber) continue;
if(OrderType() == OP_BUY ) NumBuyTrades++;
if(OrderType() == OP_SELL ) NumSellTrades++;
}
NumPositions = NumBuyTrades + NumSellTrades;
return (NumPositions);
}
页:
[1]