Please help me "OrderSend: Error code 131"

 

I get this error on validation my product but it is running well on backtests.

Please help me!



    

double GetLotSize()

{

   double minlot    = MarketInfo(Symbol(), MODE_MINLOT);

   double maxlot    = MarketInfo(Symbol(), MODE_MAXLOT);

   double leverage  = AccountLeverage();

   double lotsize   = MarketInfo(Symbol(), MODE_LOTSIZE);

   double stoplevel = MarketInfo(Symbol(), MODE_STOPLEVEL);

   double MinLots = 0.01; 

   double MaximalLots = 50.0;

   double lots = Lots;

   if(MM)

   {

      lots = NormalizeDouble(AccountFreeMargin() * Risk/100 / 1000.0, LotDigits);

      if(lots < minlot) lots = minlot;

      if (lots > MaximalLots) lots = MaximalLots;

      if (AccountFreeMargin() < Ask * lots * lotsize / leverage) 

      {

         Print("We have no money. Lots = ", lots, " , Free Margin = ", AccountFreeMargin());

         Comment("We have no money. Lots = ", lots, " , Free Margin = ", AccountFreeMargin());

      }

   }

   else lots=NormalizeDouble(Lots, Digits);

   return(lots);

}

  

Testing trading strategies on real ticks
Testing trading strategies on real ticks
  • www.mql5.com
The article provides the results of testing a simple trading strategy in three modes: "1 minute OHLC", "Every tick" and "Every tick based on real ticks" using actual historical data.
 
Tran Thanh Tuyen:

I get this error on validation my product but it is running well on backtests.

Please help me!


double GetLotSize()
{
   double minlot    = MarketInfo(Symbol(), MODE_MINLOT);
   double maxlot    = MarketInfo(Symbol(), MODE_MAXLOT);
   double leverage  = AccountLeverage();
   double lotsize   = MarketInfo(Symbol(), MODE_LOTSIZE);
   double stoplevel = MarketInfo(Symbol(), MODE_STOPLEVEL);
   double MinLots = 0.01; 
   double MaximalLots = 50.0;
   double lots = Lots;

   if(MM)
   {
      lots = NormalizeDouble(AccountFreeMargin() * Risk/100 / 1000.0, LotDigits);
      if(lots < minlot) lots = minlot;
      if (lots > MaximalLots) lots = MaximalLots;
      if (AccountFreeMargin() < Ask * lots * lotsize / leverage) 
      {
         Print("We have no money. Lots = ", lots, " , Free Margin = ", AccountFreeMargin());
         Comment("We have no money. Lots = ", lots, " , Free Margin = ", AccountFreeMargin());
      }
   }
   else lots=NormalizeDouble(Lots, Digits);
   return(lots);
}
 
Tran Thanh Tuyen:
 else lots=NormalizeDouble(Lots, Digits);

Why do you nornalize Lots to Digits?