该函数计算当前持仓的多单中亏损多单的数量。
- double GetOrderLot(){
- for (int i=0; i<OrdersTotal(); i++){
- if (OrderSelect(i, SELECT_BY_POS, MODE_TRADES)){double lot = OrderLots();}}
- if(lot==0){lot=Lots;}else{lot=lot+Lots;}
- return(lot);}
- 以此可以计算你的亏损的多单的张数
- int CheckOpenBUYPositions()
- {
- int cnt, NumPositions;
- int NumBuyTrades, NumSellTrades; // Number of buy and sell trades in this symbol
- NumBuyTrades = 0;
- NumSellTrades = 0;
- for(cnt=OrdersTotal()-1;cnt>=0;cnt--)
- {
- OrderSelect (cnt, SELECT_BY_POS, MODE_TRADES);
- if ( OrderSymbol() != Symbol()) continue;
- if ( OrderMagicNumber() != QQ) continue;
- if(OrderType() == OP_BUY &&OrderProfit() < 0)
- {
- NumBuyTrades++;
- }
- return (NumBuyTrades);
- }
- }
|