failed instant - Invalid volume

 
test on EURUSD,H1 (netting)
 2021.02.04 20:00:00   failed instant buy 0.05 EURUSD at 1.19607 sl: 1.19407 tp: 1.20607 [Invalid volume]
 2021.02.04 20:15:20   failed instant buy 0.05 EURUSD at 1.19642 sl: 1.19442 tp: 1.20642 [Invalid volume]
 2021.02.04 20:30:40   failed instant buy 0.05 EURUSD at 1.19661 sl: 1.19461 tp: 1.20661 [Invalid volume]
 2021.02.04 20:45:59   failed instant buy 0.05 EURUSD at 1.19619 sl: 1.19419 tp: 1.20619 [Invalid volume]
 2021.02.04 21:03:40   failed instant buy 0.05 EURUSD at 1.19645 sl: 1.19445 tp: 1.20645 [Invalid volume]
 2021.02.04 21:40:40   failed instant buy 0.05 EURUSD at 1.19638 sl: 1.19438 tp: 1.20638 [Invalid volume]
 2021.02.04 21:55:59   failed instant buy 0.05 EURUSD at 1.19662 sl: 1.19462 tp: 1.20662 [Invalid volume]
 2021.02.08 00:02:00   failed instant sell 0.05 EURUSD at 1.20426 sl: 1.20640 tp: 1.19440 [Invalid volume]
 2021.02.08 00:29:00   failed instant sell 0.05 EURUSD at 1.20408 sl: 1.20616 tp: 1.19416 [Invalid volume]
 2021.02.08 00:44:20   failed instant sell 0.05 EURUSD at 1.20419 sl: 1.20627 tp: 1.19427 [Invalid volume]
 2021.02.08 00:59:40   failed instant sell 0.05 EURUSD at 1.20424 sl: 1.20632 tp: 1.19432 [Invalid volume]
 2021.02.08 02:00:00   failed instant sell 0.05 EURUSD at 1.20487 sl: 1.20688 tp: 1.19488 [Invalid volume]

I am creating my own expert advisor, but unfortunately, I keep encountering the same issue when trying to publish it on the website. However, when I run a test on MT5, I get no errors, and I have even tried different currency pairs and a 5-year chart period... but still, no errors occur. I only encounter this error when trying to publish on the market. I have even gone through all the points of 'Why products are checked before they are published in the Market,' based on which I added more conditions to the code to eliminate all errors. Unfortunately, I still keep encountering them. Has anyone had a similar experience?

 
You may follow this link.
The checks a trading robot must pass before publication in the Market
The checks a trading robot must pass before publication in the Market
  • www.mql5.com
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.
 
Pavla SvajcrovaI am creating my own expert advisor, but unfortunately, I keep encountering the same issue when trying to publish it on the website. However, when I run a test on MT5, I get no errors, and I have even tried different currency pairs and a 5-year chart period... but still, no errors occur. I only encounter this error when trying to publish on the market. I have even gone through all the points of 'Why products are checked before they are published in the Market,' based on which I added more conditions to the code to eliminate all errors. Unfortunately, I still keep encountering them. Has anyone had a similar experience?

See too:

Forum on trading, automated trading systems and testing trading strategies

Desperate "No trading operations" error

Vinicius Pereira De Oliveira, 2024.04.21 14:42

It must be corrected, Juan. For example: if the EA uses a fixed volume parameter and by default this volume is set at 0.01, but during validation testing the tested symbols do not allow volume 0.01, then the EA does not open a position and will not be able to be published. So, to avoid this problem, you can use a function like the following, in addition to the volume checks recommended in the article:

//+--------------------------------------------------------------------------------------------------------------------+
//| This function normalizes the volume according to the minimum volume change step                                    |
//+--------------------------------------------------------------------------------------------------------------------+
double NormalizeVolume(double Lot)
  {
   ResetLastError();
//--- Minimal and maximal allowed volume for trade operations
   double LotMin  = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MIN);
   double LotMax  = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_MAX);
//--- Get minimal step of volume changing
   double LotStep = SymbolInfoDouble(_Symbol, SYMBOL_VOLUME_STEP);

//--- Check if an execution error occurred
   if(GetLastError() != ERR_SUCCESS)
     {
      return(WRONG_VALUE);
     }

//--- Normalizes the volume
   Lot = LotMin + MathFloor((Lot - LotMin) / LotStep) * LotStep;
   Lot = NormalizeDouble(MathMin(LotMax, MathMax(LotMin, Lot)), 2);

//--- Normalized volume
   return(Lot);
  }

 

Hi

For publication the EA has to pass more strict requirements (as mentioned above) – you need to normalize volumes and check if trades are possible to placed (enough funds etc) for more extreme conditions than your mq5 tests (for example very small account balance). So use some functions like normalize volume (mentioned above) and something like:

bool CheckMoneyForTrade(string symb,double lots,ENUM_ORDER_TYPE type, double op = 0)

  {

   ResetLastError();

//--- Getting the opening price

   MqlTick mqltick;

   SymbolInfoTick(symb,mqltick);

   double price=op;

   if(price==0){

      price = mqltick.ask;

      if(type==ORDER_TYPE_SELL || type==ORDER_TYPE_SELL_STOP || type==ORDER_TYPE_SELL_LIMIT){

         price=mqltick.bid;

      }

   }

   type = (ENUM_ORDER_TYPE)MathMod(type, 2);

   //Print(price+" "+EnumToString(type)+" "+lots);

//--- values of the required and free margin

   double margin,free_margin=AccountInfoDouble(ACCOUNT_MARGIN_FREE);

   //--- call of the checking function

   if(!OrderCalcMargin(type,symb,lots,price,margin))

     {

      //--- something went wrong, report and return false

      Print("Error in ",__FUNCTION__," code=",GetLastError());

      return(false);

     }

   //--- if there are insufficient funds to perform the operation

   if(margin>free_margin)

     {

      //--- report the error and return false

      Print("Not enough money for ",EnumToString(type)," ",lots," ",symb," Error code=",GetLastError());

      return(false);

     }

//--- checking successful

   return(true);

  

Have a nice weekend

 

So if I understand correctly, I cannot use a fixed lot size? For example, 0.01, because it's too small, but at the same time, I can't use a larger lot size (0.05) because it tests situations where there are insufficient funds in the account. Therefore, I must create a "flexible" lot size that adjusts dynamically?

Do I understand this correctly?

 
Pavla Svajcrova #:

So if I understand correctly, I cannot use a fixed lot size? For example, 0.01, because it's too small, but at the same time, I can't use a larger lot size (0.05) because it tests situations where there are insufficient funds in the account. Therefore, I must create a "flexible" lot size that adjusts dynamically?

Do I understand this correctly?

You can use a fixed lot size, But there might be test cases with no trading operations. That could cause the validation procedure to fail.
 
Pavla Svajcrova #So if I understand correctly, I cannot use a fixed lot size? For example, 0.01, because it's too small, but at the same time, I can't use a larger lot size (0.05) because it tests situations where there are insufficient funds in the account. Therefore, I must create a "flexible" lot size that adjusts dynamically? Do I understand this correctly?

No, that's not quite it... We are talking about two checks (among many others) that must be carried out by your EA to pass automatic validation: normalization and volume verification (to correct the current error) and sufficiency check of funds to trade... Let's go from the beginning:

1. The article suggested by Yashar presents, with examples, the tests that the EA must pass during automatic validation for publication on the Market, among which I highlight:

2. You can see that the first test highlighted above is checking the sufficiency of funds to trade, which is what Marzena commented on.

3. The second test highlighted is the validity of the volume of operations (which is precisely where your EA is currently showing an error). In the article, the CheckVolumeValue() function is presented, however, this function only returns whether the volume is valid or not, but does not correct for the proper volume. Therefore, I suggested above using the NormalizeVolume() function to make this correction (before checking), if necessary, understand? For example, if your EA uses a fixed lot of 0.05 in the input parameters by default, but during automatic validation the minimum lot of the tested symbol is 0.10, if normalization was not performed, an invalid volume error will occur when opening a position, but if the NormalizeVolume() function is used, the minimum symbol lot (0.10) will be used when sending the order.

4. See too:

 
Yes, I think I understand it now. It didn't make much sense to me why the validator would do that. Thank you.