统计持仓订单的多空单数量及总数量

楼主  收藏   举报   帖子创建时间:  2019-05-05 14:35 回复:0 关注量:136
函数统计持仓订单的多空单数量及总数量。

  1. int CheckOpenPositions()
  2. {
  3. int cnt, total, NumPositions;
  4. int NumBuyTrades, NumSellTrades; // Number of buy and sell trades in this symbol
  5. NumBuyTrades = 0;
  6. NumSellTrades = 0;
  7. total=OrdersTotal();
  8. for(cnt=0;cnt<TOTAL;CNT++)
  9. {
  10. OrderSelect (cnt, SELECT_BY_POS, MODE_TRADES);
  11. if ( OrderSymbol() != Symbol()) continue;
  12. if ( OrderMagicNumber() != MagicNumber) continue;
  13. if(OrderType() == OP_BUY ) NumBuyTrades++;
  14. if(OrderType() == OP_SELL ) NumSellTrades++;
  15. }
  16. NumPositions = NumBuyTrades + NumSellTrades;
  17. return (NumPositions);
  18. }
打赏