Cualquier pregunta de los recién llegados sobre MQL4 y MQL5, ayuda y discusión sobre algoritmos y códigos - página 266

 
danil77783:

Artyom buenas tardes. Me llamo Daniel. Mi pregunta es la siguiente. He escrito mi Asesor Experto en MQL4, para ser más precisos, reescrito a partir del video tutorial. Aparentemente hay algunos errores en él, pero no compila bien.

El compilador mostrará los errores especificando la línea y la posición en la línea. Por favor, remítase a ellos

Inserta el texto del programa usando el botón SRC encima del texto de tu mensaje - ¡mira, es mejor!

//+------------------------------------------------------------------+
//|                                                        test7.mq4 |
//|                        Copyright 2017, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+

#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict

También podría adjuntar un archivo - entonces se vería en el MetaEditor inmediatamente

 
LRA:

El compilador generará errores indicando la línea y la posición en la línea. Remítase a ellos

Inserta el texto del programa usando el botón SRC encima del texto de tu mensaje - ¡¡¡mira, es mejor!!!

También puede adjuntar un archivo - entonces se vería en MetaEditor inmediatamente


Perdón por el comportamiento incorrecto, me corrijo, te doy mi palabra :) Estoy agotado absolutamente....

//+------------------------------------------------------------------+
//|                                                        test7.mq4 |
//|                        Copyright 2017, MetaQuotes Software Corp. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2017, MetaQuotes Software Corp."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property strict
//-------------------------------------------------------------------
extern double lots            = 0.1;
extern int    TakeProfit      = 300;
extern int    StopLoss        = 50;
extern int    Magic           = 777; 
extern int    Slippage        = 3;
//-------------------------------------------------------------------
extern string TMA             = "Параметры индикатора TMA";
extern string TimeFrame       = "current time frame";
extern int    HalfLength      = 56;
extern int    Price           = PRICE_CLOSE;
extern double ATRMultiplier   = 2.0;
extern int    ATRPeriod       = 100;
extern bool   Interpolate     = true;
//-------------------------------------------------------------------
double PriceHigh, PriceLow, SL ,TP;
int ticet;


//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   if (Digits == 3 || Digits == 5);
   {
       TakeProfit *=10;
       StopLoss   *=10;
       Slippage   *=10;
   }  
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   
  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
    PriceHigh = iCustom(NULL, 0, "TMA_Fair", TimeFrame, HalfLength, Price, ATRMultiplier, ATRPeriod, Interpolate, 1, 0);  
    PriceLow  = iCustom(NULL, 0, "TMA_Fair", TimeFrame, HalfLength, Price, ATRMultiplier, ATRPeriod, Interpolate, 2, 0);  
    
    if (CountSell() == 0 && Bid >= PriceHigh)
    {
      tik et = OrderSend(Symbol(), OP_SELL, lots, Bid, Slippage, 0, 0, "TMA robot", Magic, 0, Red);  
      if (tiket > 0)
      {
          SL = NormalizeDouble(Bid + StopLoss*Point, Digits);
          TP = NormalizeDouble(Bid - TakeProfit*Point, Digits);
          
          if (OrderSelect(ticet, SELECT_BY_TICKET)) 
              OrderModify(tiket, OrderOpenPrice(), SL, TP, 0);
        }
    }
  }
//--------------------------------------------------------------------------------------------
 if (CountBuy() == 0 && Ask <= PriceLow)
    {
      tiket = OrderSend(Symbol(), OP_BUY, lots, Ask, Slippage, 0, 0, "TMA robot", Magic, 0, Blue);  
      if (tiket > 0)
      {
          TP = NormalizeDouble(Ask + TakeProfit*Point, Digits);
          SL = NormalizeDouble(Ask - StopLoss*Point, Digits);
          
          if (OrderSelect(ticet, SELECT_BY_TICKET)) 
              OrderModify(tiket, OrderOpenPrice(), SL, TP, 0);
        }
    }
//+------------------------------------------------------------------+
int CountSell() 
  {
    int count = 0;
    for (int trade = OrdersTotal()-1; trade>=0; trade--)
    {
       if (OrderSelect(trade, SELECT_BY_POS, MODE_TRADES))
       {
          if (OrderSymbol() == Symbol() && OrderMagicNumber) == Magic && OrderType() == OP_SELL)
             count++;
       }   
    }
    return(count);
  }
//-----------------------------------------------------------------------------------------------  
  int CountBuy() 
  {
    int count = 0;

    for (int trade = OrdersTotal()-1; trade>=0; trade--)
    {
       if (OrderSelect(trade, SELECT_BY_POS, MODE_TRADES))
       {
          if (OrderSymbol() == Symbol() && OrderMagicNumber) == Magic && OrderType() == OP_BUY)
             count++;
       }   
    }
    return(count);
  }

He marcado las líneas con errores, archivo..... adjunto, por favor eche un vistazo, ¡gracias de antemano!

 
 
danil77783:

Me disculpo por el comportamiento incorrecto, me corregiré, te doy mi palabra :) Estoy completamente agotado ....

He marcado líneas con errores, he adjuntado el archivo....., por favor, búsquelo, ¡gracias de antemano!

¿Es tan difícil ver que ticet y tiket son variables diferentes?

¿Y no se puede ver el paréntesis de cierre sin el paréntesis de apertura también?

 
Muchas gracias por su ayuda!! .... Se han arreglado todos los errores con uno que no puedo entender. Te pido ayuda. ¿Dónde he metido la pata otra vez?
 
danil77783:
Muchas gracias por su ayuda!! .... Se han arreglado todos los errores con uno que no puedo entender. Te pido ayuda. ¿Dónde he metido la pata otra vez?
Si tienes este bloque fuera del cuerpo de la función OnTick, quita una llave.
 
Alekseu Fedotov:
Tienes este bloque fuera del cuerpo de la función OnTick, quita un soporte.

Y entonces faltará un soporte.

El corchete sobre la línea seleccionada debe moverse hacia abajo, antes de la línea menos.

}
//+------------------------------------------------------------------+
 
Alexey Viktorov:

Y entonces faltará un soporte.

El corchete sobre la línea resaltada debe desplazarse hacia abajo antes de la línea de menos.

Oh, sí, deberías.

 

Todo!!! .... Muchas gracias. Lo compiló. ¡Funciona!

 
danil77783: Todo!!! .... Muchas gracias. Lo compiló. ¡Funciona!

¿Cuál es la recompensa? También se puede descartar esta pieza de aquí con la función de vacío. Pruébalo...

//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
   
  }
Razón de la queja: