Discussion of article "The checks a trading robot must pass before publication in the Market" - page 3

 
Bogdan Bovykin:

I mean to make it as a panel? And check it that way? Or how?

just open any trade manually at the moment and this EA is attached to the chart to the ticket of the open order.

ok

If YOU wrote the utility yourself, YOU can open a trade in the tester in INIT and the assistant will manage it.

 

If the Expert Advisor has passed the tests in the terminal and opens trades, then in the automatic check it writes an error that no trades have been opened (pair and TF are the same), respectively it does not pass the "Automatic check"

Coincidence? I don't think so!

What to do?

 
I had the same error recently, I just had to force open a trade in inite
 

Is it possible for MetaQuotes to generate a template for developers? It will make it easier for developers and also save MetaQuotes tons of money and resources on checking submitted EAs. 

‌Have the template for developer in the code base

https://www.mql5.com/en/code/mt4/experts/best‌

 
Alain Verleyen:

That's an interesting article, unfortunately there are too much errors (typo or even logical errors in the proposed code), and it will probably confuse more people than help them at some points.

//+------------------------------------------------------------------+
//| Return the maximum allowed volume for an order on the symbol     |
//+------------------------------------------------------------------+
double NewOrderAllowedVolume(string symbol)
  {
   double allowed_volume=0;
//--- get the limitation on the maximal volume of an order
   double symbol_max_volume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MAX);
//--- get the limitation on the volume by a symbol
   double max_volume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_LIMIT);

//--- get the volume of the open position by a symbol
   double opened_volume=PositionVolume(symbol);
   if(opened_volume>=0)  There is no opened positions
     {
      //--- if we have exhausted the volume
      if(max_volume-opened_volume<=0)
         return(0);

      //--- volume of the open position doesn't exceed max_volume
      double orders_volume_on_symbol=PendingsVolume(symbol);
      allowed_volume=max_volume-opened_volume-orders_volume_on_symbol;
      if(allowed_volume>symbol_max_volume) allowed_volume=symbol_max_volume;
     }
   return(allowed_volume);
  }

Logical error. If there is no position yet, you still have to check the pendings volume and calculate allowed volume. This code returns allowed_volume=0 if there is no position already opened without taking pendings into account.

Why?  In this cace we check pending orders volume too
 
Alain Verleyen:


+ missing parameter (PrintFormat has for %, but only 3 parameters are provided).

Thank you! Fixed

bool OrderModifyCheck(ulong ticket,double price,double sl,double tp)
  {
//--- select order by ticket
   if(orderinfo.Select(ticket))
     {
      //--- point size and name of the symbol, for which a pending order was placed
      string symbol=orderinfo.Symbol();
      double point=SymbolInfoDouble(symbol,SYMBOL_POINT);
      int digits=(int)SymbolInfoInteger(symbol,SYMBOL_DIGITS);
      //--- check if there are changes in the Open price
      bool PriceOpenChanged=(MathAbs(orderinfo.PriceOpen()-price)>point);
      //--- check if there are changes in the StopLoss level
      bool StopLossChanged=(MathAbs(orderinfo.StopLoss()-sl)>point);
      //--- check if there are changes in the Takeprofit level
      bool TakeProfitChanged=(MathAbs(orderinfo.TakeProfit()-sl)>tp);
      //--- if there are any changes in levels
      if(PriceOpenChanged || StopLossChanged || TakeProfitChanged)
         return(true);  // order can be modified      
      //--- there are no changes in the Open, StopLoss and Takeprofit levels
      else
      //--- notify about the error
         PrintFormat("Order #%d already has levels of Open=%.5f SL=%.5f TP=%.5f",
                     ticket,orderinfo.PriceOpen(),orderinfo.StopLoss(),orderinfo.TakeProfit());
     }
//--- came to the end, no changes for the order
   return(false);       // no point in modifying 
  }
 
Alain Verleyen:

Similar error as point 2° above.

And same errors also in OrderModifyCheck() mql4 version.


All fixed, thank you!

 
Alain Verleyen:

bool OrderModifyCheck(ulong ticket,double price,double sl,double tp)
  {
//--- select order by ticket
   if(orderinfo.Select(ticket))
     {
      //--- point size and name of the symbol, for which a pending order was placed
      string symbol=orderinfo.Symbol();
      double point=SymbolInfoDouble(symbol,SYMBOL_POINT);
      int digits=(int)SymbolInfoInteger(symbol,SYMBOL_DIGITS);
      //--- check if there are changes in the Open price
      bool PriceOpenChanged=(MathAbs(orderinfo.PriceOpen()-price)>point);
      //--- check if there are changes in the StopLoss level
      bool StopLossChanged=(MathAbs(orderinfo.StopLoss()-sl)>point);

An other logical error. Changing a SL/TP by 1 point is allowed. It should be >=

As far as I remember we use such practice just in order to do not get refusion from trade sercver due the price changing for the time while our trade request reaches to server

It is just more secure approach.

 
Alain Verleyen:

bool OrderModifyCheck(ulong ticket,double price,double sl,double tp)
  {
//--- select order by ticket
   if(orderinfo.Select(ticket))
     {
      //--- point size and name of the symbol, for which a pending order was placed
      string symbol=orderinfo.Symbol();
      double point=SymbolInfoDouble(symbol,SYMBOL_POINT);
      int digits=(int)SymbolInfoInteger(symbol,SYMBOL_DIGITS);
      //--- check if there are changes in the Open price
      bool PriceOpenChanged=(MathAbs(orderinfo.PriceOpen()-price)>point);
      //--- check if there are changes in the StopLoss level
      bool StopLossChanged=(MathAbs(orderinfo.StopLoss()-sl)>point);
      //--- check if there are changes in the Takeprofit level
      bool TakeProfitChanged=(MathAbs(orderinfo.TakeProfit()-sl)>tp);
      //--- if there are any changes in levels
      if(PriceOpenChanged || StopLossChanged || TakeProfitChanged)

+ typo error, should be "-tp)>=point);"

Thank you! fixed
 
bool TakeProfitChanged=(MathAbs(orderinfo.TakeProfit()-sl)>tp);

//--

bool TakeProfitChanged=(MathAbs(orderinfo.TakeProfit()-tp)>point);