What are all the things that automatic validation checks?

To add comments, please log in or register
Tonny Obare
72369
Tonny Obare  
I am still having problems. Service desk referred me back to forum and sorry cant publicize the code. Ea complies to all this https://www.mql5.com/en/articles/2555 but automatic validation always returns a no trade error. On my side trading works in all conditions like strategy tester, demo account etc code contains no restriction based on account types.
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...
Tonny Obare
72369
Tonny Obare  
No one has solution? 😕 I also noticed the moderator tab in the product edit section no longer appears.
Marco vd Heijden
Moderator
8173
Marco vd Heijden  

have you made the necessary calls to,

TerminalInfoInteger
MQLInfoInteger
AccountInfoInteger
AccountInfoDouble
SymbolInfoInteger
SymbolInfoSessionTrade
OrderCheck

Functions and their params ?
TERMINAL_TRADE_ALLOWED
MQL_TRADE_ALLOWED
ACCOUNT_TRADE_EXPERT
ACCOUNT_TRADE_ALLOWED
SYMBOL_ORDER_MODE
SYMBOL_ORDER_MARKET
SYMBOL_ORDER_LIMIT
SYMBOL_ORDER_STOP
SYMBOL_ORDER_STOP_LIMIT
SYMBOL_ORDER_SL
SYMBOL_ORDER_TP
SYMBOL_TRADE_MODE_DISABLED
SYMBOL_TRADE_MODE_LONGONLY
SYMBOL_TRADE_MODE_SHORTONLY
SYMBOL_TRADE_MODE_CLOSEONLY
SYMBOL_TRADE_MODE_FULL
SYMBOL_VOLUME_MIN
SYMBOL_VOLUME_MAX
SYMBOL_VOLUME_STEP

There can be mnore, or less, but this is what i usually check as a base stamp before trying to open a position.

Tonny Obare
72369
Tonny Obare  
Marco vd Heijden:

have you made the necessary calls to,

There can be mnore, or less, but this is what i usually check as a base stamp before trying to open a position.

I have these function for checking inputs

//----------check user input---------------
// return 1 if error is found
void CheckUserInput()
  {

   if(TakeProfit<0 || StopLoss<0)
     {
      Alert("EA stopped: Check your settings. SL and TP cant have a negative value.");
      //Reset=1;
      return(1);
     }

   if(RiskPercentage<=0 && Lots<=0)
     {
      Alert("EA stopped: Check your settings. Either Lots or RiskPercentage must have a value.");
      //Reset=1;
      return(1);
     }

   double minstop=MarketInfo(NULL,MODE_STOPLEVEL);
   if((TakeProfit>0 && TakeProfit<minstop) || (StopLoss>0 && StopLoss<minstop))
     {
      Alert("EA stopped: This pair requires minimum stop values of ",minstop," points.");
      //Reset=1;
      return(1);
     }

   double Minlot=MarketInfo(Symbol(),MODE_MINLOT);
   double Maxlot=MarketInfo(Symbol(),MODE_MAXLOT);
   double MarginNeeded=MarketInfo(Symbol(),MODE_MARGINREQUIRED)*Lots;
   if(RiskPercentage<=0 && Lots<Minlot)
     {
      Alert("EA stopped: Lot size cant be lower than ",Minlot," or higher than ",Maxlot);
      //Reset=1;
      return(1);
     }

   if(MarginNeeded>=AccountFreeMargin() && RiskPercentage<=0 && Lots>0)
     {
      Alert("EA stopped: Lot size too big for current margin.");
      //Reset=1;
      return(1);
     }

  }
//---------------------------------

The following checks for enough money

//--------------------------------------------------------
// Check for enough money for trade size
//--------------------------------------------------------
/*
Example:
CheckMoneyForTrade(NULL,lots,OP_BUY)
*/

bool CheckMoneyForTrade(string symb,double lots,int type)
  {
   double free_margin=AccountFreeMarginCheck(symb,type,lots);
//-- if there is not enough money
   if(free_margin<0)
     {
      string oper=(type==OP_BUY)? "Buy":"Sell";
      Print("Not enough money for ",oper," ",lots," ",symb," Error code=",GetLastError());
      return(false);
     }
//--- checking successful
   return(true);
  }
//-----------------------------------------------------------

this one checks the correctness of the volume

//+------------------------------------------------------------------+
//| Check the correctness of the order volume                        |
//+------------------------------------------------------------------+
bool CheckVolumeValue(double volume,string &description)
  {
//--- minimal allowed volume for trade operations
   double min_volume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MIN);
   if(volume<min_volume)
     {
      description=StringFormat("Volume is less than the minimal allowed SYMBOL_VOLUME_MIN=%.2f",min_volume);
      return(false);
     }

//--- maximal allowed volume of trade operations
   double max_volume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MAX);
   if(volume>max_volume)
     {
      description=StringFormat("Volume is greater than the maximal allowed SYMBOL_VOLUME_MAX=%.2f",max_volume);
      return(false);
     }

//--- get minimal step of volume changing
   double volume_step=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_STEP);

   int ratio=(int)MathRound(volume/volume_step);
   if(MathAbs(ratio*volume_step-volume)>0.0000001)
     {
      description=StringFormat("Volume is not a multiple of the minimal step SYMBOL_VOLUME_STEP=%.2f, the closest correct volume is %.2f",
                               volume_step,ratio*volume_step);
      return(false);
     }
   description="Correct volume value";
   return(true);
  }

//-------------------------------------------------------------------

Below is an excerpt of modifying trades. The SYMBOL_TRADE_FREEZE_LEVEL is factored in

            if((sTakeProfit>0 && OrderTakeProfit()==0) && (sStopLoss>0 && OrderStopLoss()==0))
              { // both not set
               if((OrderType()==OP_BUY) && (tpb-Bid>SYMBOL_TRADE_FREEZE_LEVEL*_Point) && (Bid-slb>SYMBOL_TRADE_FREEZE_LEVEL*_Point)){ bool OrdMod5=OrderModify(OrderTicket(),0,slb,tpb,0,CLR_NONE); }
               if((OrderType()==OP_SELL) && (Ask-tps>SYMBOL_TRADE_FREEZE_LEVEL*_Point) && (sls-Ask>SYMBOL_TRADE_FREEZE_LEVEL*_Point)){ bool OrdMod6=OrderModify(OrderTicket(),0,sls,tps,0,CLR_NONE); }

              }

            if(sTakeProfit>0 && OrderTakeProfit()==0 && sStopLoss==0)
              {// if tp not 0
               if((OrderType()==OP_BUY) && (tpb-Bid>SYMBOL_TRADE_FREEZE_LEVEL*_Point)){ bool OrdMod1=OrderModify(OrderTicket(),0,OrderStopLoss(),tpb,0,CLR_NONE); }
               if((OrderType()==OP_SELL) && (Ask-tps>SYMBOL_TRADE_FREEZE_LEVEL*_Point)){ bool OrdMod2=OrderModify(OrderTicket(),0,OrderStopLoss(),tps,0,CLR_NONE); }
              }

            if(sStopLoss>0 && OrderStopLoss()==0 && sTakeProfit==0)
              {// if sl not 0
               if((OrderType()==OP_BUY) && (Bid-slb>SYMBOL_TRADE_FREEZE_LEVEL*_Point)){ bool OrdMod3=OrderModify(OrderTicket(),0,slb,OrderTakeProfit(),0,CLR_NONE);  }
               if((OrderType()==OP_SELL) && (sls-Ask>SYMBOL_TRADE_FREEZE_LEVEL*_Point)){ bool OrdMod4=OrderModify(OrderTicket(),0,sls,OrderTakeProfit(),0,CLR_NONE);  }
              }

Automatic validation is the problem. Because before they removed the moderator tab Ive never had problems with automatic validation. Perhaps there are latest changes that cause this.

Marco vd Heijden
Moderator
8173
Marco vd Heijden  

Well why didn't you say it was MQL4 ?

I don't use that anymore.

And it looks like your missing out on a lot of checks right there, not just one.

If trading is not allowed for whatever reason, and your EA will still try to send an order, there will be an error.

These checks are good because they will filter out the trash EA's from the decent ones.

Tonny Obare
72369
Tonny Obare  
Marco vd Heijden:

Well why didn't you say it was MQL4 ?

I don't use that anymore.

And it looks like your missing out on a lot of checks right there, not just one.

If trading is not allowed for whatever reason, and your EA will still try to send an order, there will be an error.

These checks are good because they will filter out the trash EA's from the decent ones.

Thanks for your reply. Yes its for mt4. Many still use mt4 the most popular platform. The automatic validation returns the "no trades opened error" only that one error. Started happening only after latest changes in the submission page.

Alessandro Boraso
721
Alessandro Boraso  
Tonny Obare:

I have these function for checking inputs

The following checks for enough money

this one checks the correctness of the volume

Below is an excerpt of modifying trades. The SYMBOL_TRADE_FREEZE_LEVEL is factored in

Automatic validation is the problem. Because before they removed the moderator tab Ive never had problems with automatic validation. Perhaps there are latest changes that cause this.

I m troubling with automatic validation too. While backtesting my ea with mt4 strategy tester, no errors found in the Journal. The same ea, on automatic validation , makes a test from 6 4 2016 to 27 5 2016 founding 10 errors. All of them are ordersend error 131 - invalid trade volume - tried to place the Normalize Volume function before Start() and then , placed at the bottom of code. Both can t fix It!!!! Helppp
Keith Watford
Moderator
14011
Keith Watford  
Alessandro Boraso:
I m troubling with automatic validation too. While backtesting my ea with mt4 strategy tester, no errors found in the Journal. The same ea, on automatic validation , makes a test from 6 4 2016 to 27 5 2016 founding 10 errors. All of them are ordersend error 131 - invalid trade volume - tried to place the Normalize Volume function before Start() and then , placed at the bottom of code. Both can t fix It!!!! Helppp

I don't know that function.

Start() in an EA nowadays?

Alessandro Boraso
721
Alessandro Boraso  
Keith Watford:

I don't know that function.

Start() in an EA nowadays?

In order my functions are : onInit () Start() and There is all the body of program. So the normalize volume function was placed either at end of OnInit () or at the end of Start() ...without fixing the 131 
Keith Watford
Moderator
14011
Keith Watford  
I don't know what you are referring to by the normalize volume function.
Tonny Obare
72369
Tonny Obare  
These required checks are so many its like an entire ea by themselve but my automatic validation is only returning the no trade error only that one.
123
To add comments, please log in or register