错误、漏洞、问题 - 页 1802

 
Alexey Kozitsyn:
你是否建议在每次打勾时都要这样做?
我支持对OnBookEvent()的每个触发器进行同步 :(
 
prostotrader:
我支持在OnBookEvent()的每个触发器上进行同步 :(
这里没有问题,问题是除了这个之外,建议每次都要调用CopyRates()....。在我看来,这似乎是某种发脾气......
 
Alexey Kozitsyn:
没有问题,问题是除了这个之外,建议每次都调用CopyRates()....。在我看来,这似乎是在发脾气......

:)

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

这是我在SD的教育方式

 
prostotrader:

:)

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

如果你想说什么或展示什么,请适当展示......我不想猜测你这里有什么功能以及它的作用。

已添加。

是你教我的吗?而你没有给出一个实施方案?

 
Alexey Kozitsyn:

如果你想说什么或展示什么,请适当展示......我不想猜测你这里有什么功能以及它的作用。

已添加。

是你教我的吗?而你没有给出一个实施方案?

什么是正常的?

他们说,在两分钟内,数据被卸载,为了保持同步

他们让我给巴斯打电话

//+------------------------------------------------------------------+
//| 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);
}
我将寻找完整的实施方案。
 

这里是

//+------------------------------------------------------------------+
// 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);
}


通过调用GetBars,我们正在备份同步或试图检索数据

 
prostotrader:

什么是正常的?

他们说,两分钟后,数据被卸载,为了保持同步

他们说要给Bars打电话

//+------------------------------------------------------------------+
//| 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);
}

这些不就是类似物吗。

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

是的,在我看来,如果没有同步,Bars()返回0。我必须做一个测试...

 
Alexey Kozitsyn:
你是说应该在每一次打勾时都这样做吗?
为什么?一个行动就足够了。

只要在市场概览中选择了该符号,并且该符号的历史记录被专家顾问持有,那么它就会保持同步。由专家顾问持有意味着你需要至少每2分钟访问一次这个历史记录,例如通过复制一个条形。如果历史是同步的,就不会在复制一个条形图上花费时间--只需要几个处理器周期。或者,就像刚才在这里说的,要求提供条数,也是几个时钟周期
 
Slawa:
为什么?一个行动就足够了。

只要在市场审查中选择了该符号,并且该符号的历史记录被专家顾问持有,它就会保持同步。专家顾问持有意味着你需要至少每2分钟访问一次这个历史记录,比如说复制一个柱子。如果历史是同步的,那么就不会在复制一个条上花费时间--只需要几个处理器的时钟。

这些指标是否包括2分钟的间隔时间?

是的,通过检查同步化的事实,也会保持同步化吗?

 
Alexey Kozitsyn:

这些指标是否包括2分钟的间隔?

是的,同步检查是否也会保持同步?

这也适用于指标。创建一个1分钟的计时器,询问你感兴趣的所有时间序列的条数

同步不是通过检查同步的事实来举行的。