Market Validator ERROR: there are no trading operations

 

Good Morning! I am trying to put an EA on the market, but the validator does not accept it.

In addition, the validator does not say the cause of the problem. The only error message is:

"test on EURUSD,H1 there are no trading operations

test on NZDUSD,H1 there are no trading operations

test on GBPUSDcheck,M30 there are no trading operations

test on XAUUSDcheck,Daily there are no trading operations"


But I did a Backtest of these assets in these timeframes and there was no error, the orders were opened normally.

If anyone has any idea what could be wrong, I would be very grateful.

This is the EA code:

//+------------------------------------------------------------------+
//|                                                 Test RSI MQL.mq4 |
//|                                                Paulo Martins Jr. |
//|                                https://www.mql5.com/users/narfal |
//+------------------------------------------------------------------+
#property copyright "Desenvolvido por Paulo Martins Jr"
#property link      "https://www.mql5.com/en/users/narfal" 
#property version   "1.00"
#property strict

#define   MagicNumber  1010

extern int    StopLoss = 200;
extern int    TakeProfit = 200;
extern int    TrailingStop = 30;
extern int    Step = 5; 
extern double FixedLots = 0.01;
extern bool   AutoLot = false;
extern int    MaxSpread = 100;
extern int    Timeframe = 0; 
extern int    RSI_Period = 9;
extern int    RSI_Top  = 70;
extern int    RSI_Down = 30;

int err, bars, okbuy, oksell;
double sl, tp, spread, RSI, Lots;
string vol = "Lot Size";


//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---

//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
Comment("EA is Working!" "\n"
" Current Spread is: ", spread);

spread=MarketInfo(Symbol(),MODE_SPREAD);

//---
Trail();
OpenPattern();


  }
 
//+------------------------------------------------------------------+
//| Expert trading function                                          |
//+------------------------------------------------------------------+
void OpenPattern()
  {
RSI = iRSI(Symbol(),Timeframe,RSI_Period,PRICE_CLOSE,0);
// BUY     
   if(RSI < RSI_Down) 
    {okbuy = 1;}

   if(RSI > RSI_Down && okbuy == 1)
     {
      okbuy = 0;

        {
         if(StopLoss>0)
          {sl = Ask-StopLoss*Point;}
         if(TakeProfit>0)
          {tp = Ask+TakeProfit*Point;}
          
                  if( (bars < Bars) 
                  && (spread <= MaxSpread) 
                  && CheckMoneyForTrade(Symbol(), LotSize(),OP_BUY)
                  && CheckVolumeValue(LotSize(), vol)
                  && IsNewOrderAllowed()) 
         {
         err=OrderSend(Symbol(),OP_BUY,LotSize(),NormalizeDouble(Ask,Digits),3,NormalizeDouble(sl,Digits),NormalizeDouble(tp,Digits),"MightOne",MagicNumber,0,Blue);
         bars = Bars;
         }
         
         if(err<0)
          {Print("OrderSend() OP_BUY ERROR");}
        }
      CloseAllPos(0); //Close Sells.
     }

// SELL
   if(RSI > RSI_Top) 
    {oksell=1;}

   if(RSI < RSI_Top && oksell==1)
     {
      oksell=0;

        {
         if(StopLoss>0)
          {sl=Bid+StopLoss*Point;}
          
         if(TakeProfit>0)
          {tp=Bid-TakeProfit*Point;}
          
                  if( (bars < Bars) 
                  && (spread <= MaxSpread) 
                  && CheckMoneyForTrade(Symbol(), LotSize(),OP_SELL)
                  && CheckVolumeValue(LotSize(), vol)
                  && IsNewOrderAllowed()) 
         {
         err=OrderSend(Symbol(),OP_SELL,LotSize(),NormalizeDouble(Bid,Digits),3,NormalizeDouble(sl,Digits),NormalizeDouble(tp,Digits),"MightOne",MagicNumber,0,Red);
         bars = Bars;
         }
         
         if(err<0)
         {Print("OrderSend()-OP_SELL. ERROR");}
        }
      CloseAllPos(1); //Close Buys
     }
  }
  
//+------------------------------------------------------------------+
// Close positions
//+------------------------------------------------------------------+
int CloseAllPos(int type)
  {
   int buy=1; int sell=1;
   int i,b=0;

   if(type==1)
     {
      while(buy==1)
        {
         buy=0;
         for(i=0;i<OrdersTotal();i++)
           {
            if( (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true) && (OrderMagicNumber()==MagicNumber))
              {
               if(OrderType()==OP_BUY && OrderSymbol()==Symbol())
                 {buy=1;if(OrderClose(OrderTicket(),OrderLots(),Bid,3,Violet)){};}
                 }else{buy=0;
              }
           }
         if(buy==0){return(0);}
        }
     }
   if(type==0)
     {
      while(sell==1)
        {
         sell=0;
         for(i=0;i<OrdersTotal();i++)
           {
            if( (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true) && (OrderMagicNumber()==MagicNumber))
              {
               if(OrderType()==OP_SELL && OrderSymbol()==Symbol())
                 {sell=1;if(OrderClose(OrderTicket(),OrderLots(),Ask,3,Violet)){}; }
                 }else{sell=0;
              }
           }
         if(sell==0){return(0);}
        }
     }
   return(0);
  }
  
//+------------------------------------------------------------------+
// Trailing positions
//+------------------------------------------------------------------+
void Trail()
  { 
         for(int i=0; i<OrdersTotal(); i++)
            {  
if( (OrderSelect(i,SELECT_BY_POS,MODE_TRADES)==true) && (OrderMagicNumber()==MagicNumber) && (OrderSymbol()==Symbol()))
{
if(OrderType()==OP_SELL)
{
            if(TrailingStop>0)
              {
               if((OrderOpenPrice()-Ask)>(Point*TrailingStop))
                 {
                  if((OrderStopLoss()>(Ask+(TrailingStop+Step)*Point)) || (OrderStopLoss()==0))
                    {
                     //--- modify order and exit
                     if(!OrderModify(OrderTicket(),OrderOpenPrice(),Ask+Point*TrailingStop,OrderTakeProfit(),0,Red))
                        Print("OrderModify error ",GetLastError());
  
                    }
                 }
              }
              }
              
 if(OrderType()==OP_BUY)
{ 
            if(TrailingStop>0)
              {
               if(Bid-OrderOpenPrice()>Point*TrailingStop)
                 {
                  if(OrderStopLoss()<Bid-(TrailingStop+Step)*Point) // Step to avoid error 1.
                    {
                     //--- modify order and exit
                     if(!OrderModify(OrderTicket(),OrderOpenPrice(),Bid-Point*TrailingStop,OrderTakeProfit(),0,Green))
                        Print("OrderModify error ",GetLastError());
                     return;
                    }
                 }
              }
              }
}
}
}
//+------------------------------------------------------------------+
// Define the lot size
//+------------------------------------------------------------------+
double LotSize()
{
if (AutoLot == true)
Lots = NormalizeDouble((AccountEquity()*0.01/3000),2);
else
Lots = FixedLots;

return Lots;
}

//+------------------------------------------------------------------+
// Check if there are money for trade
//+------------------------------------------------------------------+
bool CheckMoneyForTrade(string symb, double lots,int type)
  {
   double free_margin=AccountFreeMarginCheck(symb,type,lots);
   //-- se não houver dinheiro suficiente
   if(free_margin<0)
     {
      string oper=(type==OP_BUY)? "Buy":"Sell";
      Print("Not enough money for ", oper," ",lots, " ", symb, " Error code=",GetLastError());
      return(false);
     }
   //--- a verificação foi realizada com sucesso
   return(true);
  }

//+------------------------------------------------------------------+
//|  Check if the volume is correct                                  |
//+------------------------------------------------------------------+
bool CheckVolumeValue(double volume,string &description)
  {
//--- valor mínimo permitido para operações de negociação
   double min_volume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MIN);
   if(volume<min_volume)
     {
      description=StringFormat("Volume inferior ao mínimo permitido SYMBOL_VOLUME_MIN=%.2f",min_volume);
      return(false);
     }

//--- volume máximo permitido para operações de negociação
   double max_volume=SymbolInfoDouble(Symbol(),SYMBOL_VOLUME_MAX);
   if(volume>max_volume)
     {
      description=StringFormat("Volume superior ao máximo permitido SYMBOL_VOLUME_MAX=%.2f",max_volume);
      return(false);
     }

//--- obtemos a gradação mínima do volume
   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("O volume não é múltiplo da gradação mínima SYMBOL_VOLUME_STEP=%.2f, volume mais próximo do valido %.2f",
                               volume_step,ratio*volume_step);
      return(false);
     }
   description="Valor válido do volume";
   return(true);
  }

//+------------------------------------------------------------------+
//| Check if it's possible to add more orders                        |
//+------------------------------------------------------------------+
bool IsNewOrderAllowed()
  {
//--- obtemos o número de ordens pendentes permitidas na conta
   int max_allowed_orders=(int)AccountInfoInteger(ACCOUNT_LIMIT_ORDERS);

//--- se não houver restrição, retornamos true, e poderemos enviar a ordem
   if(max_allowed_orders==0) return(true);

//--- se chegamos até esta linha, significa que existe restrição; ficamos sabendo quantas ordens foram colocadas
   int orders=OrdersTotal();

//--- retornamos o resultado da comparação
   return(orders<max_allowed_orders);
  }
 
Paulo Martins Barbosa Junior:


Olá,

este fórum é em Português.

 
Rogerio Giannetti Torres:

Olá,

este fórum é em Português.

Obrigado, eu realmente não tinha visto.
Vou postar no fórum em inglês tbm.

 
Paulo Martins Barbosa Junior:

Good Morning! I am trying to put an EA on the market, but the validator does not accept it.

In addition, the validator does not say the cause of the problem. The only error message is:

"test on EURUSD,H1 there are no trading operations

test on NZDUSD,H1 there are no trading operations

test on GBPUSDcheck,M30 there are no trading operations

test on XAUUSDcheck,Daily there are no trading operations"


But I did a Backtest of these assets in these timeframes and there was no error, the orders were opened normally.

If anyone has any idea what could be wrong, I would be very grateful.

This is the EA code:

SIM, o Validator disse exatamente qual é o erro....

"there are no trading operations"

 
Flavio Jarabeck:

SIM, o Validator disse exatamente qual é o erro....

"there are no trading operations"

Ok, mas a questão é, o que está causando esse erro se no backtests e mesmo na conta real o expert abre ordens normalmente?
 
Paulo Martins Barbosa Junior:
Ok, mas a questão é, o que está causando esse erro se no backtests e mesmo na conta real o expert abre ordens normalmente?

Veja o relatório... por algum motivo, nós ativos testados ele não abre operações. Para muitos casos o validador é engessado.
 
Flavio Jarabeck:

Veja o relatório... por algum motivo, nós ativos testados ele não abre operações. Para muitos casos o validador é engessado.

O relatório só fala justamente isso: nenhuma ordem aberta.
Aí eu vou no backtest, no ativo e timeframe indicado no relatório e as ordens são abertas normalmente.
Na operação real as ordens também são abertas sem nenhum erro.

 
Paulo Martins Barbosa Junior:

O relatório só fala justamente isso: nenhuma ordem aberta.
Aí eu vou no backtest, no ativo e timeframe indicado no relatório e as ordens são abertas normalmente.
Na operação real as ordens também são abertas sem nenhum erro.

Você usa elementos gráficos que seu EA "lê"?
 
Flavio Jarabeck:
Você usa elementos gráficos que seu EA "lê"?

Eu consegui resolver, muito obrigado!
Estava faltando uma função para verificar se o tamanho do lot era permitido.

Razão: