エラー、バグ、質問 - ページ 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:

言いたいこと、見せたいことがあるなら、きちんと見せてほしい...。ここにある機能が何なのか、何をするものなのか、推測するのはやめましょう。

追加されました。

教えてくれたんですか?そして、実装はしなかったのですか?

普通ってなんだろう?

2分でデータがアンロードされるとのことで、同期を維持するために

バーズに 電話するように言われました。

//+------------------------------------------------------------------+
//| 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:

普通ってなんだろう?

2分後にデータがアンロードされるとのことで、同期をとるために

バーズに 電話するように言われた。

//+------------------------------------------------------------------+
//| 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:
これをすべてのティックに行うべきだとおっしゃるのですか?
なぜ?ワンアクションで十分です。

マーケット概観でシンボルを選択し、そのシンボルの履歴をExpert Advisorが保持している間、同期が保たれます。Expert Advisorによる保持は、1本のバーをコピーするなどして、少なくとも2分に一度はこの履歴にアクセスする必要があることを意味します。履歴が同期していれば、1本のバーをコピーするのにかかる時間はなく、わずか数プロセッササイクルで済みます。あるいは、今ここで言われたように、バーの 数を求め、また数クロックサイクル
 
Slawa:
なぜ?ワンアクションで十分です。

マーケットレビューでシンボルが選択され、そのシンボルの履歴がExpert Advisorに保持されている限り、同期が保たれるのです。Expert Advisorの保有は、1本のバーをコピーするなどして、少なくとも2分に1回はこの履歴にアクセスする必要があることを意味します。履歴が同期していれば、1本のバーをコピーするために時間を費やすことはなく、数個のプロセッサクロックがあればよいのです。

インジケーターには2分間隔が含まれていますか?

はい、また、同期の事実を確認することで、同期も保持されるのでしょうか?

 
Alexey Kozitsyn:

インジケーターには2分間隔が含まれていますか?

はい、また、シンクロの事実を確認することで、シンクロも保持されるのでしょうか?

また、指標にも適用されます。1分タイマーを作成し、興味のあるすべてのタイムスケールのバー 数を尋ねます。

同期の事実を確認することで、同期が保たれるわけではありません。