评论

收藏

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

avatar 老周 | 2579 人阅读 | 0 人评论 | 2017-03-21

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

  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. }
复制代码


""
还没有人打赏,支持一下
您需要登录后才可以回帖 登录 | 注册 微信登录

EA之家评论守则