Hard time to upload My EA in MQL5 market. - page 2

Sergey Golubev
Moderator
124460
Sergey Golubev  

Forum on trading, automated trading systems and testing trading strategies

Tortured by the error there are no trading operations

Aleksandr Kononov, 11/20/20/07 7:46 PM

Here's how I went through the validation. An Expert Advisor without stops and order modifications, but on all timeframes .

The validator issued error 131 (wrong lot) and there were no trade operations. This is my first advisor, so there were probably all the mistakes that were possible.

First, I added all the comments in English to the trading function checks. that is, if the Expert Advisor does not trade, it should issue an error in Print ().

I also added a free margin check and removed all ExpertRemove (), but that did not help, the errors were the same.

 void buy()
  {
   if (AccountFreeMarginCheck( Symbol (),OP_BUY,Lots)> 0 )
     {
       if ( OrderSend ( _Symbol ,OP_BUY,Lots,Ask,Slip,SLb, 0 ,comment,Magic, 0 ,Green)< 1 )
         Print ( " Buy ​​order error !" + IntegerToString ( _Period , 0 ) + " Error code = " + IntegerToString ( GetLastError (), 0 ));
     }
   else
       Print ( "Not enough money!" + " Error code = " + IntegerToString ( GetLastError (), 0 ));
       /// ExpertRemove();
   return ;   
  }

Then I made several changes at once and it is not clear which of this helped.

Clearing errors at the beginning and at the end of the advisor's work, checking the availability of quotes on all TFs

 int OnInit ()
  {
     ResetLastError ();   

       for ( int cycle= 1 ; cycle<= 5 ; cycle++)
     {
       switch (cycle)
        {
         case 1 :
            TF = PERIOD_D1 ;
             break ;
         case 2 :
            TF = PERIOD_H4 ;
             break ;
         case 3 :
            TF = PERIOD_H1 ;
             break ;
         case 4 :
            TF = PERIOD_M15 ;
             break ;
         case 5 :
            TF = PERIOD_M5 ;
             break ;
        }
   if ( iTime ( _Symbol ,TF,Limit)< 1 )
     Print ( "Missing quotes! " + IntegerToString (TF, 0 ) + " Timeframe" + " Error = " + IntegerToString ( GetLastError (), 0 ));            
     }      
   return ( INIT_SUCCEEDED );
  }
//****************************
void OnDeinit ( const int reason)
  {  
   Alert ( "Error = " + IntegerToString ( GetLastError (), 0 ));
   ResetLastError ();
  }

and changed the lot calculation for all cases if the step is (0.1), (0.01) and even (0.001)

 double lotstep = MarketInfo( Symbol (),MODE_LOTSTEP);

   Lots = NormalizeDouble (AccountEquity()/ 10000 *Lot_for_10K, 3 );
   if (lotstep> 0.001 )
   Lots = ( MathRound (Lots/lotstep))*lotstep;    
   Lots = MathMax (Lots,MarketInfo( Symbol (),MODE_MINLOT));
   Lots = MathMin (Lots,MarketInfo( Symbol (),MODE_MAXLOT));

in the end, we can say that it quickly turned out to fix everything, only 2 days and about 10 attempts


Mosleur Rahaman Riad
287
Duplicate code will no-go and shouldn't be on the list of things you don't want in the codebase. It's the maintainability of your code that suffers the hardest from duplicate code, and sacrificing maintainability is a bad thing to do. Since most time is spent, by far, on maintenance you should use a (fresh/ unique) new code, that may solve the problem, anyway I don't know much about this it's just an opinion
Sergey Golubev
Moderator
124460
Sergey Golubev  

Forum on trading, automated trading systems and testing trading strategies

Tortured by the error there are no trading operations

Nauris Zukas , 2021.11.22 18:30

Still, I found a problem, by default in the input parameters there is a limit on the maximum lot of positions.

 input double MaxLots= 0.1 ;
...
lots = MathMin (lots, MaxLots );

This did not skip opening positions if SYMBOL_VOLUME_MIN in the validator is 0.20. It is impossible for the validator to set by default such a small limit on the maximum lot of positions.


Zubaidah
183
Zubaidah  
Sergey Golubev # :

thanks master, i will try again

Zubaidah
183
Zubaidah  
Sergey Golubev # :

sete

Sergey Golubev # :

after I called Getlasseror Ondeinit, an Allert error 4200 appeared when EA was uninstalled....???

Zubaidah
183
Zubaidah  

unsolved

Chinedum Jesse Mgbikeh
123

I tried uploading my EA for sale, but I'm getting an error message saying "please recompile your product with new compiler".

Please what do I do?