Error en asesor experto

 

Hola a todos!

                               Necesito ayuda, he realizado un Asesor Experto, y a mi entender no debería de tener problemas pero cuando lo paso por el Backtesting, me da unos errores que desconozco y que no encuentro en Metacuotes tampoco para solucionarlo. ¿Podría alguien ayudarme y comentarme donde he cometido el error del código?

 

Os adjunto el código y una foto de los errores que me da.

//+------------------------------------------------------------------+
//|                                          EA_MultiZigZag_V2.3.mq4 |
//|                                          © ® Code Nr.: 202211107 |
//+------------------------------------------------------------------+
#property description   "Robot utilizando MultiZigZag_V4."
#property version       " "
#property strict

// === Variables globales ===.
extern double  MagicNumber     = 202211107;                 // MagicNumber .:
extern double  TakeProfit      = 0;                      // Take Profit (0 = sin Take Profit) .:
extern double  StopLoss        = 10;                     // Stop Loss .:
extern int     Ratio           = 44;                     // Ratio .:
extern double  Porcentaje      = 0.25;                    // Porcentaje(%) tamaño operación/balance .:
extern double  Lotes           = 0.05;                   // Lotaje en pips .:
extern double  LotesMin        = 0.03;                   // Lotaje mínimo .:
extern string  Comentario      = "EA_MultiZigZag_V2.3_"; // Comentario operación abierta.:
extern int     vela            = 2;                 // Número de vala anterior .:


// === Variables globales ===
double   pips,SL,TP,PriceHigh1,PriceLow1,PriceHigh2,PriceLow2,PriceHigh3,
         PriceLow3,ticksize,HighSL,LowSL,Gastos,PipsGastos,SLTemp;
int bars,ticket = 0;

bool OpenBuy,W,OpenSell = false;
datetime TimeDn, TimeUp;

//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//---
   Lotaje();
   ResetLastError();
   PriceLow1 = iCustom(NULL, PERIOD_CURRENT, "..\\Indicators\\MultiZigZag_V4", "12,12,12", "5,5,5", "8,8,8", "225000,45000,1000", "1,5,60", 3, 0, vela);
   PriceHigh1 = iCustom(NULL, PERIOD_CURRENT, "..\\Indicators\\MultiZigZag_V4", "12,12,12", "5,5,5", "8,8,8", "225000,45000,1000", "1,5,60", 3, 0, vela);
   PriceLow2 = iCustom(NULL, PERIOD_CURRENT, "..\\Indicators\\MultiZigZag_V4", "12,12,12", "5,5,5", "8,8,8", "225000,45000,1000", "1,5,60", 3, 0, vela);
   PriceHigh2 = iCustom(NULL, PERIOD_CURRENT, "..\\Indicators\\MultiZigZag_V4", "12,12,12", "5,5,5", "8,8,8", "225000,45000,1000", "1,5,60", 3, 0, vela);
   Print(GetLastError());
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {

//PriceLow1 = iCustom(NULL,0,"..\\Indicators\\MultiZigZag_V4.mq4",0,vela);
//PriceHigh1 = iCustom(NULL,0,"..\\Indicators\\MultiZigZag_V4.mq4",1,vela);
//PriceLow2 = iCustom(NULL,0,"..\\Indicators\\MultiZigZag_V4.mq4",2,vela);
//PriceHigh2 = iCustom(NULL,0,"..\\Indicators\\MultiZigZag_V4.mq4",3,vela);
//---
   for(int i=0; i>=10; i++)
     {
      long TicketEnUso = Ticket();
      if(TicketEnUso > 0)
        {
         if(OrderSelect(TicketEnUso,SELECT_BY_TICKET,MODE_TRADES))
           {
            if(OrderType() == OP_BUY)     // Apertura de operación de Compra o Alcista.
              {
               if(PriceHigh1 > 0 && PriceHigh2 > 0)
                  CloseTrade(TicketEnUso);
              }
            if(OrderType() == OP_SELL)    // Apertura de operación de Venta o Bajista.
              {
               if(PriceLow1 > 0 && PriceLow2> 0)
                  CloseTrade(TicketEnUso);
              }
           }
        }
      if(TicketEnUso < 1)
        {
         if(PriceLow1 > 0 && PriceLow2)
            OpenTrade(OP_BUY);
         if(PriceHigh1 > 0 && PriceHigh2 > 0)
            OpenTrade(OP_SELL);
        }

      //PriceLow1 = iCustom(NULL,0,"..\\Indicators\\MultiZigZag_V4.mq4",0,i);
      //PriceHigh1 = iCustom(NULL,0,"..\\Indicators\\MultiZigZag_V4.mq4",1,i);
      //PriceLow2 = iCustom(NULL,0,"..\\Indicators\\MultiZigZag_V4.mq4",2,i);
      //PriceHigh2 = iCustom(NULL,0,"..\\Indicators\\MultiZigZag_V4.mq4",3,i);
     }
  }
//+------------------------------------------------------------------+
//+------------------------------------------------------------------+
//===================================================================//
//+------------------------------------------------------------------+
//|                       FUNCIONES PROPIAS                          |
//+------------------------------------------------------------------+
//===================================================================//
//+------------------------------------------------------------------+
//|  Inicio Función "OpenTrade"                                      |
//+------------------------------------------------------------------+
//---
void  OpenTrade(int Type)
  {
//---

   long TicketEnUso = Ticket();
   string Tipo;
   Lotes = Lotaje();

   if(Lotes < LotesMin)
      Lotes = LotesMin;

   if(AccountFreeMargin()<(1000*Lotes))         //--- Filtro apertura por falta de dinero en Margin.
     {
      Print("No hay suficiente dinero disponible en Free Margin");
      return;
     }
//---
   if(Digits == 5 || Digits == 3)
     {
      pips = Point*10;
     }
   else
     {
      pips = Point;
     }

//---
   double SLMin = MarketInfo(Symbol(),MODE_STOPLEVEL);
   if(StopLoss <= SLMin)
      StopLoss = SLMin + 1;

   if(Ratio == 0)
      TakeProfit = TakeProfit;
   else
      TakeProfit = StopLoss * Ratio;

   if(TakeProfit == 0)
      TakeProfit = TakeProfit;
   else
     {
      if(Ratio == 0)
         TakeProfit = TakeProfit;
      else
         TakeProfit = StopLoss * Ratio;
     }
//---

   double SL = NormalizeDouble(StopLoss*Point,Digits);
   double TP = NormalizeDouble(TakeProfit*Point,Digits);

   double SLBuy = NormalizeDouble(OrderOpenPrice()- pips,Digits);
   double SLSell = NormalizeDouble(OrderOpenPrice()+ pips,Digits);

   double TPBuy=NormalizeDouble(OrderOpenPrice()+ pips,Digits);
   double TPSell=NormalizeDouble(OrderOpenPrice()- pips,Digits);

   SLBuy = NormalizeDouble(Bid - SL,Digits);
   SLSell = NormalizeDouble(Ask + SL,Digits);

   TPBuy = NormalizeDouble(Ask + TP,Digits);
   TPSell = NormalizeDouble(Bid - TP,Digits);

//--- selección del precio por tipo de operación.
   double Precio = 0;

   if(Type == OP_BUY)
     {
      Precio = Ask;
      Tipo = "_BUY";
      SL = SLBuy;
     }
   else
     {
      Precio = Bid;
      Tipo = "_SELL";
      SL = SLSell;
     }

   ResetLastError();
   if(OrderSend(NULL,Type,Lotes,Precio,10,SL,0,Comentario + _Symbol + Tipo,MagicNumber,0,clrNONE) < 1)
      Print(GetLastError());
  }
//+------------------------------------------------------------------+
//===================================================================//
//+------------------------------------------------------------------+
//|  Inicio Función "CloseTrade"                                      |
//+------------------------------------------------------------------+
//---
void  CloseTrade(long NoTicket)
  {
   double Precio = 0;
   if(OrderSelect(NoTicket,SELECT_BY_TICKET,MODE_TRADES))
     {
      if(OrderType() == OP_BUY)
         Precio = Bid;
      else
         Precio = Ask;
      ResetLastError();
      if(OrderClose(NoTicket,Lotes,Precio,10,clrNONE));
      Print(GetLastError());
     }
  }
//+------------------------------------------------------------------+
//===================================================================//
//+------------------------------------------------------------------+
//|  Inicio Función "Ticket"                                         |
//+------------------------------------------------------------------+
//---
long Ticket()
  {
//---
   for(int Oper = 0; Oper < OrdersTotal(); Oper++)
     {
      if(OrderSelect(Oper,SELECT_BY_POS, MODE_TRADES))
        {
         if(MagicNumber == OrderMagicNumber())
            return(OrderTicket());
        }
     }
   return(0);
  }
//+------------------------------------------------------------------+
//===================================================================//
//+------------------------------------------------------------------+
//|  Inicio Función "Lotaje"                                         |
//+------------------------------------------------------------------+
//---
double Lotaje()
  {
//---
   if(Porcentaje > 0.05)
     {
      Porcentaje = 0.05;
     }

   double  Balance = NormalizeDouble(AccountBalance(),0);
   double  Lotaje = ((Balance * Porcentaje) /10) / (StopLoss*SymbolInfoDouble(_Symbol,SYMBOL_TRADE_TICK_VALUE))/100;
   Lotaje = NormalizeDouble(Lotaje,2);

   return(Lotaje);
  }
//+------------------------------------------------------------------+
//===================================================================//
//+------------------------------------------------------------------+

errores


Muchas gracias.

 
Son errores en el historial del símbolo. No son errores en el propio Asesor Experto
 
Enrique Enguix #:
Son errores en el historial del símbolo. No son errores en el propio Asesor Experto

OK! Muchas gracias.

Razón de la queja: