Errores, fallos, preguntas - página 2409

 
Queridos desarrolladores ¿Vas a arreglar el sitio? Cada vez que entro hay una notificación sobre una actualización del producto. Miro esta alerta y vuelve a aparecer. ¡No debería ser así!
 
Alexey Kozitsyn:
Queridos desarrolladores ¿Vas a arreglar el sitio? Cada vez que entro - una notificación de actualización del producto. Miro a través de esta alerta y se produce de nuevo. ¡No debería ser así!


No tengo este tipo de error por producto.

Hay un error general de no lectura de mensajes.

El error se produce cuando hay varias pestañas abiertas, hasta que no se cierran, no se leen.

Hay una cosa más - tienes que ir a este mensaje dos veces - entonces será marcado como leído.

Esto puede ayudar a los desarrolladores.

 

Falta el gráfico del indicador (indicador para contratos de futuros, si no es BR-4.19, entonces introduzca int NextFutMonth = 3; //Futuros NextFutMonth (mes))

//+------------------------------------------------------------------+
//|                                                   BR_Scalper.mq5 |
//|                                      Copyright 2019 prostotrader |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019 prostotrader"
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_separate_window
#property indicator_buffers 1
#property indicator_plots   1

//--- plot Label1
#property indicator_label1  "Spread"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrYellow
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1

//#property indicator_maximum 30
//#property indicator_minimum -30

#define  on_call -111
//
input int NextFutMonth = 1;    //След фьючерс (мес.)
input int aBars = 30;          //Бары  
//
double Buff[];
double pr_last, sec_last;
string sec_symbol;
bool pr_book, sec_book;
int event_cnt;

//+------------------------------------------------------------------+
//| Indicator Set second Symbols function                            |
//+------------------------------------------------------------------+
string SetSecSymbol(const string aSymbol)
{
  int str_tire = StringFind(aSymbol, "-");
  int str_tochka = StringFind(aSymbol, ".", str_tire);
  int str_size = StringLen(aSymbol);
  if((str_tire > 0) && (str_tochka > 0) && (str_size > 0))
  {
    string str_month = StringSubstr(aSymbol, str_tire + 1, str_tochka - str_tire - 1);
    string str_year = StringSubstr(aSymbol, str_tochka + 1, str_size - str_tochka - 1);
    long aMonth = StringToInteger(str_month);
    long aYear = StringToInteger(str_year);
    if((aMonth > 0) && (aYear > 0))
    {
      long n_month = aMonth + long(NextFutMonth);
      long add_year = (n_month - 1) / 12;
      aYear += add_year;
      str_year = IntegerToString(aYear); 
      aMonth = n_month - add_year * 12;
      str_month = IntegerToString(aMonth);
      return(StringSubstr(aSymbol, 0, str_tire + 1) + str_month + "." + str_year);
    } 
  }
  return("");
}
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
{
  int a_bars = Bars(Symbol(), PERIOD_CURRENT);
  if(a_bars < aBars + 1)
  {
    Alert("На графике не хватает баров!");
    return(INIT_FAILED);
  } 
  event_cnt = 0;
  sec_symbol = SetSecSymbol(Symbol());
  if(SymbolSelect(sec_symbol, true) == false) return(INIT_FAILED);
  pr_book = MarketBookAdd(Symbol());
  sec_book = MarketBookAdd(sec_symbol);
  IndicatorSetInteger(INDICATOR_DIGITS, 0);
  IndicatorSetString(INDICATOR_SHORTNAME, "BR_Scalper");
//---  
  SetIndexBuffer(0, Buff, INDICATOR_DATA);
  PlotIndexSetDouble( 0, PLOT_EMPTY_VALUE, EMPTY_VALUE);
  ArraySetAsSeries(Buff, true );
  return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+
// Custom indicator DeInit function                                  |
//+------------------------------------------------------------------+
void OnDeinit( const int reason )
{
  if(pr_book == true) MarketBookRelease(Symbol());
  if(sec_book == true) MarketBookRelease(sec_symbol);
  if(reason == REASON_INITFAILED)
  {
    Print("Индикатор удалён! Причина - ошибка инициализации.");
    string short_name = ChartIndicatorName(ChartID(), 1, 0);
    ChartIndicatorDelete(ChartID(), 1, short_name); 
  }
}
//+------------------------------------------------------------------+
// Custom indicator On book event function                           |
//+------------------------------------------------------------------+
void OnBookEvent( const string& symbol )
{
  if((symbol == Symbol()) || (symbol == sec_symbol))
  {
    sec_last = SymbolInfoDouble(sec_symbol, SYMBOL_LAST);
    pr_last = SymbolInfoDouble(Symbol(), SYMBOL_LAST);
    double price[]; 
    OnCalculate( event_cnt, event_cnt, on_call, price ); 
  }
}
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const int begin,
                const double &price[])
{
  if(prev_calculated == 0)
  {
    ArrayInitialize(Buff, EMPTY_VALUE);
  }
  else
  {
    if(begin == on_call)
    {
      for(int i = aBars - 1; i > 0; i--)
      {
        Buff[i] = Buff[i - 1];
      }
    }
    else
    {
     sec_last = SymbolInfoDouble(sec_symbol, SYMBOL_LAST);
     pr_last = SymbolInfoDouble(Symbol(), SYMBOL_LAST); 
     Buff[aBars] = EMPTY_VALUE;
    } 
    Buff[0] = (sec_last - pr_last) /Point();
  } 
//---    
  event_cnt = rates_total;  
//--- return value of prev_calculated for next call
  return(rates_total);
}
//+------------------------------------------------------------------+

Pero cuando se pone

#property indicator_maximum 30
#property indicator_minimum -30

funciona bien

 

El probador cierra las operaciones utilizando las cotizaciones de otro instrumento.


1. precio de apertura del eurusd 1,30935.

2. Precio de cierre 1,60704. No era un precio tan alto, pero en ese momento era para otro instrumento gbpusd.





La prueba se realiza para dos símbolos eurusd y gbpusd. Si se excluye el gbpusd, el error desaparece.


 
Aleksey Sergan:

El probador cierra las operaciones utilizando las cotizaciones de otro instrumento.


1. precio de apertura del eurusd 1,30935.

2. Precio de cierre 1,60704. No era ese precio, pero sí lo era en ese momento para otro símbolo gbpusd.





La prueba se realiza para dos símbolos eurusd y gbpusd. Si se excluye el gbpusd, el error desaparece.


¿Dónde está el código de este asesor milagroso? Doy el 99% de que estás trabajando con clases y utilizas una variable estática en alguna parte.

 
Vladimir Karputov:

¿Dónde está el código de este asesor milagroso? El 99% apuesta que trabaja con clases y utiliza una variable estática en alguna parte.

Vladimir, ¿estás bromeando?

 
Andrey Barinov:

Vladimir, ¿estás bromeando?

Todavía estoy esperando una respuesta deAleksey Sergan. En función de la respuesta habrá una segunda parte principal de la pregunta.

 
Vladimir Karputov:

Todavía estoy esperando una respuesta deAleksey Sergan. En función de la respuesta habrá una segunda parte principal de la pregunta.

Ya veo. Así que no estás bromeando después de todo...

A veces un error terminal es sólo un error terminal.
 
Vladimir Karputov:

¿Dónde está el código de este asesor milagroso? El 99% apuesta que trabaja con clases y utiliza una variable estática en alguna parte.

El código tiene varios miles de líneas. No tiene sentido adjuntarlo, no hay variables estáticas. Hay clases. En cualquier caso es un error de los probadores.

 
Andrey Barinov:

Lo entiendo. Así que no estás bromeando después de todo...

A veces un error terminal es sólo un error terminal.

Nuh-uh :)