评论

收藏

计算当前持仓多单中亏损的多单数量

avatar 老周 | 921 人阅读 | 0 人评论 | 2017-03-20

该函数计算当前持仓的多单中亏损多单的数量。

  1. double GetOrderLot(){
  2. for (int i=0; i<OrdersTotal(); i++){
  3. if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)){double lot = OrderLots();}}
  4. if(lot==0){lot=Lots;}else{lot=lot+Lots;}
  5. return(lot);}
  6. 以此可以计算你的亏损的多单的张数
  7. int CheckOpenBUYPositions()
  8. {
  9. int cnt, NumPositions;
  10. int NumBuyTrades, NumSellTrades; // Number of buy and sell trades in this symbol
  11. NumBuyTrades = 0;
  12. NumSellTrades = 0;
  13. for(cnt=OrdersTotal()-1;cnt>=0;cnt--)
  14. {
  15. OrderSelect (cnt, SELECT_BY_POS, MODE_TRADES);
  16. if ( OrderSymbol() != Symbol()) continue;
  17. if ( OrderMagicNumber() != QQ) continue;
  18. if(OrderType() == OP_BUY &&OrderProfit() < 0)
  19. {
  20. NumBuyTrades++;
  21. }
  22. return (NumBuyTrades);
  23. }
  24. }
复制代码


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

EA之家评论守则