Errores, fallos, preguntas - página 1802

 
Alexey Kozitsyn:
¿Sugiere hacer esto en cada tic?
Apoyo la sincronización en cada disparo de OnBookEvent() :(
 
prostotrader:
Apoyo la sincronización en cada disparo de OnBookEvent() :(
No hay preguntas aquí, la cuestión es que además de esto, se sugiere llamar a CopyRates().... cada vez. Esto me parece una especie de rabieta...
 
Alexey Kozitsyn:
No hay preguntas aquí, la cuestión es que además de esto, se sugiere llamar a CopyRates().... cada vez. Esto me parece una pataleta...

:)

void OnBookEvent(const string &symbol)
{
  if(symbol == Symbol())
  {
    GetBars(Symbol(), time_frame);
  }  
}

Así es como me enseñaron en SD

 
prostotrader:

:)

void OnBookEvent(const string &symbol)
{
  if(symbol == Symbol())
  {
    GetBars(Symbol(), time_frame);
  }  
}

Si quieres decir o mostrar algo, por favor muéstralo correctamente... No quiero adivinar qué función tienes aquí y qué hace.

Añadido:

¿Me has enseñado? ¿Y no dio una implementación?

 
Alexey Kozitsyn:

Si quieres decir o mostrar algo, por favor muéstralo correctamente... No quiero adivinar qué función tienes aquí y qué hace.

Añadido:

¿Me has enseñado? ¿Y no dio una implementación?

¿Qué es lo normal?

Dijeron que en dos minutos se descargan los datos y para mantener la sincronización

me dijeron que llamara a Bares.

//+------------------------------------------------------------------+
//| Custom indicator Get bars function                               |
//+------------------------------------------------------------------+
int GetBars(string symbol, ENUM_TIMEFRAMES period)
{
  if(!IsStopped())
  {
    if(SymbolIsSynchronized(symbol))
    {
      if(bool(SeriesInfoInteger(symbol, period, SERIES_SYNCHRONIZED)))
      {
        int a_bars = Bars(symbol, period);  
        if(a_bars > 0)
        {
          return(a_bars);
        }
        else
        {
          return(GetLocalData(symbol, period));
        }  
      }
      else
      {
        return(GetLocalData(symbol, period));
      }    
    }  
    else
    {
      return(LoadServerData(symbol, period));
    }  
  }  
  return(0);
}
Buscaré la aplicación completa.
 

Aquí está

//+------------------------------------------------------------------+
// Custom indicator Check timer function                             |
//+------------------------------------------------------------------+
bool CheckTimer(const ulong start_value, const ulong per_value)
{
  ulong end_value = GetMicrosecondCount();
  if(end_value < start_value)
  {
    if((start_value - end_value) >= per_value) return(true);
  }
  else
  {
    if((end_value - start_value) >= per_value) return(true);
  }
  return(false);
}
//+------------------------------------------------------------------+
//| Custom indicator Get local data function                         |
//+------------------------------------------------------------------+
int GetLocalData(const string a_symbol, ENUM_TIMEFRAMES a_period)
{
  long first_date;
  int fail_cnt = 0;
  while((fail_cnt < 3) && !IsStopped())
  {
    first_date = long( SeriesInfoInteger(a_symbol, PERIOD_M1, SERIES_TERMINAL_FIRSTDATE));
    if(first_date > 0)
    {
      int f_cnt = 0;
      datetime times[1];
      long a_bars = 0;
      while((f_cnt < 5) && !IsStopped())
      {
        if(bool(SeriesInfoInteger(a_symbol, PERIOD_M1, SERIES_BARS_COUNT, a_bars)))
        {
          if ( a_bars > 0 )
          {
            if( bool(SeriesInfoInteger(a_symbol, a_period, SERIES_BARS_COUNT, a_bars)))
              if(a_bars > 0) return(int(a_bars));
          }
        }
        else
        {
//--- force timeseries build
          CopyTime(a_symbol, a_period, 0, 1, times);
          ulong start_tick = GetMicrosecondCount();
          while(!CheckTimer(start_tick, 5000))
          {
            f_cnt--;
            f_cnt++;
          }  
        }
        f_cnt++;
      }
    }
    else
    {
      ulong start_tick = GetMicrosecondCount();
      while(!CheckTimer(start_tick, 5000))
      {
        fail_cnt--;
        fail_cnt++;
      }
    }
//---  
    fail_cnt++;
  }
  return(0);
}
//+------------------------------------------------------------------+
//| Custom indicator Get server data function                        |
//+------------------------------------------------------------------+
int LoadServerData(const string a_symbol, ENUM_TIMEFRAMES period)
{
  int fail_cnt = 0;
  while((fail_cnt < 5) && !IsStopped())
  {  
    long first_date = long(SeriesInfoInteger(a_symbol, PERIOD_M1, SERIES_SERVER_FIRSTDATE));
    if(first_date > 0)
    {
      if(SymbolIsSynchronized(a_symbol))
      {
        return(GetLocalData(a_symbol, period));
      }  
    }
    else
    {
      ulong start_tick = GetMicrosecondCount();
      while(!CheckTimer(start_tick, 20000))
      {
        fail_cnt--;
        fail_cnt++;
      }
    }    
    fail_cnt++;
  }
  return(0);  
}
//+------------------------------------------------------------------+
//| Custom indicator Get bars function                               |
//+------------------------------------------------------------------+
int GetBars(string symbol, ENUM_TIMEFRAMES period)
{
  if(!IsStopped())
  {
    if(SymbolIsSynchronized(symbol))
    {
      if(bool(SeriesInfoInteger(symbol, period, SERIES_SYNCHRONIZED)))
      {
        int a_bars = Bars(symbol, period);  
        if(a_bars > 0)
        {
          return(a_bars);
        }
        else
        {
          return(GetLocalData(symbol, period));
        }  
      }
      else
      {
        return(GetLocalData(symbol, period));
      }    
    }  
    else
    {
      return(LoadServerData(symbol, period));
    }  
  }  
  return(0);
}


Al llamar a GetBars, estamos respaldando la sincronización o tratando de recuperar datos

 
prostotrader:

¿Qué es lo normal?

Dijeron que después de dos minutos los datos se descargan y para mantenerlos sincronizados

dijeron que llamara a Bares.

//+------------------------------------------------------------------+
//| Custom indicator Get bars function                               |
//+------------------------------------------------------------------+
int GetBars(string symbol, ENUM_TIMEFRAMES period)
{
  if(!IsStopped())
  {
    if(SymbolIsSynchronized(symbol))
    {
      if(bool(SeriesInfoInteger(symbol, period, SERIES_SYNCHRONIZED)))
      {
        int a_bars = Bars(symbol, period);  
        if(a_bars > 0)
        {
          return(a_bars);
        }
        else
        {
          return(GetLocalData(symbol, period));
        }  
      }
      else
      {
        return(GetLocalData(symbol, period));
      }    
    }  
    else
    {
      return(LoadServerData(symbol, period));
    }  
  }  
  return(0);
}

¿No son estos los análogos:

if(SymbolIsSynchronized(symbol))
if(bool(SeriesInfoInteger(symbol, period, SERIES_SYNCHRONIZED)))

Sí, me pareció que Bars() devuelve 0 si no hay sincronización... Tendré que hacer una prueba...

 
Alexey Kozitsyn:
¿Está sugiriendo que esto se haga en cada garrapata?
¿Por qué? Una sola acción es suficiente.

Mientras se selecciona un símbolo en la visión general del mercado y el historial del símbolo es mantenido por un Asesor Experto, entonces se mantiene sincronizado. El mantenimiento por parte del Asesor Experto significa que debe acceder a este historial al menos una vez cada 2 minutos, por ejemplo, copiando una barra. Si el historial está sincronizado, no se gasta tiempo en copiar una barra: sólo unos pocos ciclos del procesador. O, como se acaba de decir aquí, pedir el número de barras, también algunos ciclos de reloj
 
Slawa:
¿Por qué? Una sola acción es suficiente.

Mientras el símbolo esté seleccionado en la revisión del mercado y el historial del símbolo esté en manos del Asesor Experto, se mantendrá sincronizado. El hecho de que el Asesor Experto se mantenga significa que debe acceder a este historial al menos una vez cada 2 minutos, por ejemplo, copiando una barra. Si el historial está sincronizado, no se gasta tiempo en copiar una barra, sólo unos cuantos relojes del procesador.

¿Los indicadores incluyen un intervalo de 2 minutos?

Sí, y al comprobar el hecho de la sincronización, ¿también se mantendrá la sincronización?

 
Alexey Kozitsyn:

¿Los indicadores incluyen un intervalo de 2 minutos?

Sí, ¿la comprobación de la sincronización también se llevará a cabo?

También se aplica a los indicadores. Cree un temporizador de 1 minuto y pida el número de barras de todas las series temporales que le interesen.

La sincronización no se lleva a cabo comprobando el hecho de la sincronización.
Razón de la queja: