MQL5 EA Product Validation Errors Daily Feed

To add comments, please log in or register
Syed Oarasul Islam
979
Syed Oarasul Islam  

Hi,


I have been thinking about to to create a thread where EA Developers/Sellers can discuss and share similar errors and their possible solution on a daily basis. Because the automatic product validation software itself gets updated like all software does, possibilities for occurring new validation errors is more likely high. We can make this place as an one stop place where EA Sellers/Developers can point out newly identified errors and get quick responses or find quick solutions as well as attract the attention of Automatic Product Validation Developers/Moderators easily. 

Before uploading for Automatic Product Validation make sure your EA complies the To Do's mentioned

here: https://www.mql5.com/en/articles/2555

and here: https://www.mql5.com/en/blogs/post/686716


Here comes the errors that I am facing today...

I have been trying to upload a new version of my product for couple of days but failing every time. When I tried to upload first time then Automatic Validation failed with errors "There are no trading operations". I noticed it tried to trade with 100 lots on EURUSD, GBPUSD and XAUUSD. The error is like this:

test on EURUSD,H1 (hedging)
there are no trading operations
test on XAUUSD,D1 (hedging)
there are no trading operations
test on GBPUSD,M30 (hedging)
 2017.02.01 00:18:40   current account state: Balance: 100000.00, Credit: 0.00, Commission: 0.00, Accumulated: 0.00, Assets: 0.00, Liabilities: 0.00, Equity 100000.00, Margin: 0.00, FreeMargin: 100000.00
 2017.02.01 00:18:40   calculated account state: Assets: 0.00, Liabilities: 0.00, Equity 100000.00, Margin: 125768.00, FreeMargin: -25768.00
 2017.02.01 00:18:40   not enough money [request sell 100.00 GBPUSD at 1.25768 sl: 1.26768 tp: 1.22768]
 2017.02.01 00:18:40   failed request sell 100.00 GBPUSD at 1.25768  sl: 1.26768 tp: 1.22768 [No money]
 2017.02.01 00:18:59   current account state: Balance: 100000.00, Credit: 0.00, Commission: 0.00, Accumulated: 0.00, Assets: 0.00, Liabilities: 0.00, Equity 100000.00, Margin: 0.00, FreeMargin: 100000.00
 2017.02.01 00:18:59   calculated account state: Assets: 0.00, Liabilities: 0.00, Equity 100000.00, Margin: 125773.00, FreeMargin: -25773.00
 2017.02.01 00:18:59   not enough money [request sell 100.00 GBPUSD at 1.25773 sl: 1.26773 tp: 1.22773]
 2017.02.01 00:18:59   failed request sell 100.00 GBPUSD at 1.25773  sl: 1.26773 tp: 1.22773 [No money]
 2017.02.01 00:19:00   current account state: Balance: 100000.00, Credit: 0.00, Commission: 0.00, Accumulated: 0.00, Assets: 0.00, Liabilities: 0.00, Equity 100000.00, Margin: 0.00, FreeMargin: 100000.00
 2017.02.01 00:19:00   calculated account state: Assets: 0.00, Liabilities: 0.00, Equity 100000.00, Margin: 125773.00, FreeMargin: -25773.00
 2017.02.01 00:19:00   not enough money [request sell 100.00 GBPUSD at 1.25773 sl: 1.26773 tp: 1.22773]
 2017.02.01 00:19:00   failed request sell 100.00 GBPUSD at 1.25773  sl: 1.26773 tp: 1.22773 [No money]
 2017.02.01 00:19:20   current account state: Balance: 100000.00, Credit: 0.00, Commission: 0.00, Accumulated: 0.00, Assets: 0.00, Liabilities: 0.00, Equity 100000.00, Margin: 0.00, FreeMargin: 100000.00
 2017.02.01 00:19:20   calculated account state: Assets: 0.00, Liabilities: 0.00, Equity 100000.00, Margin: 125770.00, FreeMargin: -25770.00
 2017.02.01 00:19:20   not enough money [request sell 100.00 GBPUSD at 1.25770 sl: 1.26770 tp: 1.22770]
 2017.02.01 00:19:20   failed request sell 100.00 GBPUSD at 1.25770  sl: 1.26770 tp: 1.22770 [No money]
 2017.02.01 00:20:40   current account state: Balance: 100000.00, Credit: 0.00, Commission: 0.00, Accumulated: 0.00, Assets: 0.00, Liabilities: 0.00, Equity 100000.00, Margin: 0.00, FreeMargin: 100000.00
 2017.02.01 00:20:40   calculated account state: Assets: 0.00, Liabilities: 0.00, Equity 100000.00, Margin: 125773.00, FreeMargin: -25773.00
 2017.02.01 00:20:40   not enough money [request sell 100.00 GBPUSD at 1.25773 sl: 1.26773 tp: 1.22773]
 2017.02.01 00:20:40   failed request sell 100.00 GBPUSD at 1.25773  sl: 1.26773 tp: 1.22773 [No money]
 2017.02.01 00:21:00   current account state: Balance: 100000.00, Credit: 0.00, Commission: 0.00, Accumulated: 0.00, Assets: 0.00, Liabilities: 0.00, Equity 100000.00, Margin: 0.00, FreeMargin: 100000.00
there are no trading operations


In order to improve the situation i modified my EA where it check required margin inside OnTick() from this:

if(AccountInfoDouble(ACCOUNT_MARGIN_FREE)<(1000*lotSize())){
         Print("We have no money. Free Margin = ",AccountInfoDouble(ACCOUNT_MARGIN_FREE));
         return;
      } 

To this global function which is : 

bool CheckMoneyForTrade(string symb,double lots,ENUM_ORDER_TYPE type)
  {
//--- Getting the opening price
   MqlTick mqltick;
   SymbolInfoTick(symb,mqltick);
   double price=mqltick.ask;
   if(type==ORDER_TYPE_SELL)
      price=mqltick.bid;
//--- values of the required and free margin
   double required_margin=RobotsAccountInfo.MarginCheck(symb,type,lots,price);
   double free_margin=RobotsAccountInfo.FreeMargin();
   //--- call of the checking function

   //--- if there are insufficient funds to perform the operation
   if(required_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);
  }

After checking this function on every places where my EA tries to submit trades I realize the "Not Enough Money" error was not there anymore but then it started to show new error which is Log File Size Exceeded

log files size exceeded 2059 MB, test terminated

At this point I suspect that the log was probably getting filled out with the Print command from CheckMoneyForTrade() function. So I decided to take off the print command and re-uploaded for validation with the modified CheckMoneyForTrade():

bool CheckMoneyForTrade(string symb,double lots,ENUM_ORDER_TYPE type)
  {
//--- Getting the opening price
   MqlTick mqltick;
   SymbolInfoTick(symb,mqltick);
   double price=mqltick.ask;
   if(type==ORDER_TYPE_SELL)
      price=mqltick.bid;
//--- values of the required and free margin
   double required_margin=RobotsAccountInfo.MarginCheck(symb,type,lots,price);
   double free_margin=RobotsAccountInfo.FreeMargin();
   //--- call of the checking function

   //--- if there are insufficient funds to perform the operation
   if(required_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);
  }

This time there was no Log file Exceed error but this error:

test on EURUSD,H1 (hedging)
there are no trading operations
test on XAUUSD,D1 (hedging)
there are no trading operations
test on GBPUSD,M30 (hedging)
there are no trading operations
test on EURUSD,M1 (hedging)
there are no trading operations

Now the question is why the Automatic Validator will try to trade with 100 lot against a deposit of 100000? Isn't it violating what the EA is supposed to do? My EA is is set to 0.01% risk when I uploaded for validation. So the Automatic Validator is trying to test beyond the EA parameters. However when my EA found required margin for 100 lot is not available then it prints  Not enough money .. text from the CheckMoneyForTrade(). 

Isn't it how any EA supposed to work? If so then what is the point of stress testing with 100 lot size test and filling out the log files at the end? 

In my local terminal demo trading and strategy tester is working just fine. I even tried to upload my older versions which was once succeeded with validation but not now. You guys know any work around? 

BR

Syed

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, as a small error in the expert or indicator logic can cause losses on the trading account. That is why we have developed a series of basic checks to ensure the required quality level of the Market products. If any errors are identified by the Market...
Syed Oarasul Islam
979
Syed Oarasul Islam  

Update...

I tried to validate twice today. Still same errors. 


I still do not understand when Required margin is not available for a given trade EA should say that "Not enough money for the trade". Isn't it normal ? If so then why automatic validator is holding there?


I am so stuck. I will be really grateful if someone can point me out towards some direction.


Thanks in advance.

Marco vd Heijden
Moderator
10973
Marco vd Heijden  
   if(required_margin>free_margin)
     {
      //--- report the error and return false
      //Print("Not enough money for ",EnumToString(type)," ",lots," ",symb," Error code=",GetLastError());
      return(false);
     }

The print statement is commented out.

Your customer most likely wants to look in the log to see what happened.
Syed Oarasul Islam
979
Syed Oarasul Islam  
Marco vd Heijden:

The print statement is commented out.

Your customer most likely wants to look in the log to see what happened.

If you have read my whole story then you would notice that I commented it out to see if the log file size exceeds problem occurs or not. After commenting it out the Log file size exceed problem did not show up anymore but then error was No trade operation. The automatic validator is testing with 100 lot size against a deposit of 100000 and EA is printing Not enough money continuously which causes the log file size to exceed. I hope you now understood my problem. 

Marco vd Heijden
Moderator
10973
Marco vd Heijden  
I can't see any code that deals with position sizing in your examples.
Syed Oarasul Islam
979
Syed Oarasul Islam  
Marco vd Heijden:
I can't see any code that deals with position sizing in your examples.

My position sizing function is similar the one that is found on the Moving Average EA that comes with MT5 downlaod. Please note that I am trying to update 4th version of my product. Since I have not made any changes to the position sizing then there should be no problem with the existing position sizing function.

Syed Oarasul Islam
979
Syed Oarasul Islam  

Update...I am still stuck on this.

Heres the code for my last attempt. 

//+------------------------------------------------------------------+
//| Check margin                    |
//+------------------------------------------------------------------+
bool CheckMoneyForTrade(string symb,double lots,ENUM_ORDER_TYPE type)
  {
//--- Getting the opening price
   MqlTick mqltick;
   SymbolInfoTick(symb,mqltick);
   double price=mqltick.ask;
   if(type==ORDER_TYPE_SELL)
      price=mqltick.bid;
//--- values of the required and free margin
   double required_margin=RoboAccountInfo.MarginCheck(symb,type,lots,price);
   double free_margin=RoboAccountInfo.FreeMargin();
   //--- call of the checking function

   //--- if there are insufficient funds to perform the operation
   if(required_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);
  }
//+------------------------------------------------------------------+
//| Optimize lot sizes when UseAutoLot true                       |
//+------------------------------------------------------------------+

double lotSize(void){ 
   
   double price=0.0;
   double margin=0.0;
//--- select lot size
   if(!SymbolInfoDouble(_Symbol,SYMBOL_ASK,price))
      return(0.0);
   if(!OrderCalcMargin(ORDER_TYPE_BUY,_Symbol,1.0,price,margin))
      return(0.0);
   if(margin<=0.0)
      return(0.0);

   double lot=NormalizeDouble(AccountInfoDouble(ACCOUNT_MARGIN_FREE)*AutoLotRisks/margin,2);
//--- calculate number of losses orders without a break
   
   if(LotDecreaseFactorIfLossOccurs>0)
     {
      //--- select history for access
      HistorySelect(0,TimeCurrent());
      //---
      int    orders=HistoryDealsTotal();  // total history deals
      
      // number of losses orders without a break

      for(int i=orders-1;i>=0;i--)
        {
         ulong ticket=HistoryDealGetTicket(i);
         if(ticket==0)
           {
            Print("HistoryDealGetTicket failed, no trade history");
            break;
           }
         //--- check symbol
         if(HistoryDealGetString(ticket,DEAL_SYMBOL)!=_Symbol)
            continue;
         //--- check profit
         double profit=HistoryDealGetDouble(ticket,DEAL_PROFIT);
         if(profit>0.0)
            break;
         if(profit<0.0)
            losses++;
        }
        numoflosses=losses;
      //---
      if(losses>1)
         lot=NormalizeDouble(lot-lot*losses/LotDecreaseFactorIfLossOccurs,1);
     }
     
//--- normalize and check limits
   double stepvol=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_STEP);
   lot=stepvol*NormalizeDouble(lot/stepvol,0);

   double minvol=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MIN);
   if(lot<minvol)
      lot=minvol;

   double maxvol=SymbolInfoDouble(_Symbol,SYMBOL_VOLUME_MAX);
   if(lot>maxvol)
      lot=maxvol;
//--- return trading volume
   return(lot);
} 

Inside OnTick() I am checking CheckMoneyForTrade() before placing trade. Its working perfectly in my strategy tester and also in demo trading. I dont understand why the Automatic Validator is trying to place order with lot sizes that is more than the free margin. This is causing the Print command in CheckMoneyForTrade() to be printed continuously until the log file size exceeds. This same code has been validated in previous versions.

Syed Oarasul Islam
979
Syed Oarasul Islam  
I am surprised none can figured it out yet. I really need this to get done as one of client is waiting for this update. If you do not understand my problem then let me know I will explain it more.
KEENBASE SOFTWARE SOLUTIONS
15954
Nitin Raj  
Syed Oarasul Islam:
I am surprised none can figured it out yet. I really need this to get done as one of client is waiting for this update. If you do not understand my problem then let me know I will explain it more.

I am also stuck. 

My MT5 EA unable to pass the validation anymore. With CheckMoneyForTrade() function, EA validation fails with the error "there are no trading operations" and without CheckMoneyForTrade(), validation fails due to the error "not enough money...."


Just for the purpose of testing, I coded a function to open a buy trade on every new bar still the validation is getting failed with "there are no trading operations". The same EA is opening trades perfectly when tested on MT5 with Metaquotes demo account server.

Syed Oarasul Islam
979
Syed Oarasul Islam  
Nitin Raj:

I am also stuck. 

My MT5 EA unable to pass the validation anymore. With CheckMoneyForTrade() function, EA validation fails with the error "there are no trading operations" and without CheckMoneyForTrade(), validation fails due to the error "not enough money...."


Just for the purpose of testing, I coded a function to open a buy trade on every new bar still the validation is getting failed with "there are no trading operations". The same EA is opening trades perfectly when tested on MT5 with Metaquotes demo account server.

I have been stuck with this almost a week. Same problem. I think the problem is with the Automatic Validator's logic. Its not using the lot sizes that EA decides rather its directly testing how EA behaves with lot sizes more than free margins.

KEENBASE SOFTWARE SOLUTIONS
15954
Nitin Raj  
Syed Oarasul Islam:

I have been stuck with this almost a week. Same problem. I think the problem is with the Automatic Validator's logic. Its not using the lot sizes that EA decides rather its directly testing how EA behaves with lot sizes more than free margins.

Yes. The validator always used to stress test using bigger lot sizes and negative margin but I think it is not using the normal lot sizes anywhere in the tests thats why we are getting the error "there are no trading operations". 

To add comments, please log in or register