Please help me about the error : Invalid volume

 

Hi , everybody

I encoutered an error when i release a new version, This error has never been encountered in the previous release process , I can not find out why this happened, Please help me!

The following is the error message and source code:

bool TradeClass::SendOrder(const ENUM_ORDER_TYPE _OP,
                           const double _lots = DEFULT_TRADE_LOT,
                           const int _SL = DEFULT_TRADE_SL,
                           const int _TP = DEFULT_TRADE_TP,
                           const double _Price = 0,
                           const datetime _Expiration = 0) {
   ExeResultInt = OrderObj.OrderTotal[ORDER_TYPE_BUY_LIMIT] + OrderObj.OrderTotal[ORDER_TYPE_BUY_STOP] + OrderObj.OrderTotal[ORDER_TYPE_SELL_LIMIT] +OrderObj.OrderTotal[ORDER_TYPE_SELL_STOP];
   if(SymbolMaxOrder != 0 && ExeResultInt >= SymbolMaxOrder-1) return false;
   double SL,TP,Lot=NormalizeDouble(_lots,2);
   if(_lots >= MaxLot) Lot=MaxLot;
   else if(_lots <= MinLot) Lot=MinLot;
   SL = _SL != 0 ? SLTransfer(symbol,_OP,_SL,_Price) : _SL;
   TP = _TP != 0 ? TPTransfer(symbol,_OP,_TP,_Price) : _TP;
   t.SetExpertMagicNumber(MagicNumber);
   t.SetDeviationInPoints(Slippage);
   t.SetTypeFilling(ORDER_FILLING_IOC);
   if(_OP == ORDER_TYPE_BUY || _OP == ORDER_TYPE_SELL) {
      if(MathAbs(ASK(symbol) - BID(symbol)) > MaxSpread) return false;
      if(SL != 0 && !CheckSL(_OP,SL,Price(_OP,_Price))) return false;
      if(TP != 0 && !CheckTP(_OP,TP,Price(_OP,_Price))) return false;
      if(CheckMoneyForTrade(Lot,_OP)) {
         ExeState = t.PositionOpen(symbol,_OP,NormalizeDouble(Lot,2),Price(_OP,NormalizeDouble(_Price,digits)),NormalizeDouble(SL,digits),NormalizeDouble(TP,digits),Comment);
      }
   } else {
      if(!CheckPrice(_OP,_Price)) return false;
      if(SL != 0 && !CheckSL(_OP,SL,Price(_OP,_Price))) return false;
      if(TP != 0 && !CheckTP(_OP,TP,Price(_OP,_Price))) return false;
      if(CheckMoneyForTrade(Lot,ORDER_TYPE_BUY)) {
         if(_OP == ORDER_TYPE_BUY_LIMIT) {
            ExeState = t.OrderOpen(symbol,ORDER_TYPE_BUY_LIMIT,NormalizeDouble(Lot,2),NormalizeDouble(_Price,digits),NormalizeDouble(_Price,digits),NormalizeDouble(SL,digits),NormalizeDouble(TP,digits),0,0,Comment);
         } else if(_OP == ORDER_TYPE_SELL_LIMIT) {
            ExeState = t.OrderOpen(symbol,ORDER_TYPE_SELL_LIMIT,NormalizeDouble(Lot,2),NormalizeDouble(_Price,digits),NormalizeDouble(_Price,digits),NormalizeDouble(SL,digits),NormalizeDouble(TP,digits),0,0,Comment);
         } else if(_OP == ORDER_TYPE_BUY_STOP) {
            ExeState = t.OrderOpen(symbol,ORDER_TYPE_BUY_STOP,NormalizeDouble(Lot,2),NormalizeDouble(_Price,digits),NormalizeDouble(_Price,digits),NormalizeDouble(SL,digits),NormalizeDouble(TP,digits),0,0,Comment);
         } else if(_OP == ORDER_TYPE_SELL_STOP) {
            ExeState = t.OrderOpen(symbol,ORDER_TYPE_SELL_STOP,NormalizeDouble(Lot,2),NormalizeDouble(_Price,digits),NormalizeDouble(_Price,digits),NormalizeDouble(SL,digits),NormalizeDouble(TP,digits),0,0,Comment);
         }
      }
   }
   if(ExeState) OrderObj.RefreshOrderInfo();
   else printf(__FUNCTION__+" Failed to send order : "+GetLastError());
   return ExeState;
}
 

Please read the following ...

Articles

The checks a trading robot must pass before publication in the Market

MetaQuotes, 2016.08.01 09:30

Before any product is published in the Market, it must undergo compulsory preliminary checks in order to ensure a uniform quality standard. This article considers the most frequent errors made by developers in their technical indicators and trading robots. An also shows how to self-test a product before sending it to the Market.
Reason: