記事"トレーダーのライフハック: インジケーターで作られたファストフード"についてのディスカッション - ページ 12

 
fxsaber:

標準的なインジケーター(この記事で取り上げているのはこれだけ)は、初歩的な方法でキャッシュされる!なぜなら、入力パラメータはすべて既知だからだ。

普遍的なハッシュ関数を書くことだけが難しい。しかし、この記事ではその必要はなかった。最も単純なケースを扱っている。そしてその場合でもハッシュ関数は存在しない。

MACD サンプル4~5 MQL4 style.mq5


キャッシュなし

i = 0 Pass = 0 OnTester = 15.070 s.: Count = 9753093, 647186.0 unit/sec, Agent = C:\Program Files\Alpari Limited MT5\Tester\Agent-127.0.0.1-3000 build = 1755
i = 1 Pass = 1 OnTester = 14.969 s.: Count = 9753093, 651552.7 unit/sec, Agent = C:\Program Files\Alpari Limited MT5\Tester\Agent-127.0.0.1-3000 build = 1755


キャッシュあり

i = 0 Pass = 0 OnTester = 11.073 s.: Count = 9753093, 880799.5 unit/sec, Agent = C:\Program Files\Alpari Limited MT5\Tester\Agent-127.0.0.1-3000 build = 1755
i = 1 Pass = 1 OnTester = 11.007 s.: Count = 9753093, 886080.9 unit/sec, Agent = C:\Program Files\Alpari Limited MT5\Tester\Agent-127.0.0.1-3000 build = 1755


ワイセツ(真正面から)をしなければ25%速い。提示されたアプローチの「非効率性」に対する 批判は正当である。

 
コードを見せてもらえますか?
 
Rashid Umarov:
コードを表示できますか?
template <typename T>
struct HANDLE
{
private:  
  int Handle;
  
  T Inputs;

public:  
  HANDLE() : Handle(INVALID_HANDLE)
  {
  }
  
  bool operator ==( const T &Inputs2 ) const
  {
    return(this.Inputs == Inputs2);
  }
  
  void operator =( const T &Inputs2 )
  {
    this.Inputs = Inputs2;
  }
  
  int GetHandle()
  {
    return((this.Handle != INVALID_HANDLE) ? this.Handle : (this.Handle = this.Inputs.GetHandle()));
  }
};

template <typename T>
int GetHandle( HANDLE<T> &Handles[], const T &Inputs )
{
  const int Size = ArraySize(Handles);
  
  for (int i = 0; i < Size; i++)
    if (Handles[i] == Inputs)
      return(Handles[i].GetHandle());

  ArrayResize(Handles, Size + 1);
  Handles[Size] = Inputs;
  
  return(Handles[Size].GetHandle());
}

struct MACD
{
  string             symbol;
  ENUM_TIMEFRAMES    period;
  int                fast_ema_period;
  int                slow_ema_period;
  int                signal_period;
  ENUM_APPLIED_PRICE applied_price;
  
  MACD( void )
  {
  }
  
  MACD( const string             &isymbol,
        const ENUM_TIMEFRAMES    &iperiod,
        const int                &ifast_ema_period,
        const int                &islow_ema_period,
        const int                &isignal_period,
        const ENUM_APPLIED_PRICE &iapplied_price ) : 
        symbol((isymbol == NULL) || (isymbol == "") ? _Symbol : isymbol),
        period(iperiod == PERIOD_CURRENT ? ::Period() : iperiod),
        fast_ema_period(ifast_ema_period),
        slow_ema_period(islow_ema_period),
        signal_period(isignal_period),
        applied_price(iapplied_price)     
  {
  }
  
  int GetHandle( void ) const
  {
    return(::iMACD(this.symbol, this.period, this.fast_ema_period, this.slow_ema_period, this.signal_period, this.applied_price));
  }
  
  bool operator ==( const MACD &Inputs ) const
  {
    return((this.symbol == Inputs.symbol) &&
           (this.period == Inputs.period) &&
           (this.fast_ema_period == Inputs.fast_ema_period) &&
           (this.slow_ema_period == Inputs.slow_ema_period) &&
           (this.signal_period == Inputs.signal_period) &&
           (this.applied_price == Inputs.applied_price));
  }  
};

struct MA
{
  string             symbol;
  ENUM_TIMEFRAMES    period;
  int                ma_period;
  int                ma_shift;
  ENUM_MA_METHOD     ma_method;
  ENUM_APPLIED_PRICE applied_price;
  
  MA( void )
  {
  }
  
  MA( const string             &isymbol,
      const ENUM_TIMEFRAMES    &iperiod,
      const int                &ima_period,
      const int                &ima_shift,
      const ENUM_MA_METHOD     &ima_method,
      const ENUM_APPLIED_PRICE &iapplied_price ) :
      symbol((isymbol == NULL) || (isymbol == "") ? _Symbol : isymbol),
      period(iperiod == PERIOD_CURRENT ? ::Period() : iperiod),
      ma_period(ima_period),
      ma_shift(ima_shift),
      ma_method(ima_method),
      applied_price(iapplied_price)
  {
  }
  
  int GetHandle( void ) const
  {
    return(::iMA(this.symbol, this.period, this.ma_period, this.ma_shift, this.ma_method, this.applied_price));
  }
  
  bool operator ==( const MA &Inputs ) const
  {
    return((this.symbol == Inputs.symbol) &&
           (this.period == Inputs.period) &&
           (this.ma_period == Inputs.ma_period) &&
           (this.ma_shift == Inputs.ma_shift) &&
           (this.ma_method == Inputs.ma_method) &&
           (this.applied_price == Inputs.applied_price));
  }  
};

// iMACD の MT5 バリアント。
int iMACD2( const string             symbol,
            const ENUM_TIMEFRAMES    period,
            const int                fast_ema_period,
            const int                slow_ema_period,
            const int                signal_period,
            const ENUM_APPLIED_PRICE applied_price )
{
  static HANDLE<MACD> Handles[];  
  const MACD Inputs(symbol, period, fast_ema_period, slow_ema_period, signal_period, applied_price);
  
  return(GetHandle(Handles, Inputs));
}            

// iMA の MT5 バリアント。
int iMA2( const string             symbol,
          const ENUM_TIMEFRAMES    period,
          const int                ma_period,
          const int                ma_shift,
          const ENUM_MA_METHOD     ma_method,
          const ENUM_APPLIED_PRICE applied_price )
{
  static HANDLE<MA> Handles[];  
  const MA Inputs(symbol, period, ma_period, ma_shift, ma_method, applied_price);
  
  return(GetHandle(Handles, Inputs));
}            


IndicatorsMQL4.mqhに上記のコードを追加し、以下の変更を加えてください。

   int handle=iMACD2(symbol,timeframe,fast_ema_period,slow_ema_period,signal_period,applied_price);
//...
   int handle=iMA2(symbol,timeframe,ma_period,ma_shift,ma_method,applied_price);
 
Rashid Umarov:
インジケーターからOnCalculateを取り出し、新しい名前で少し修正し、インジケーターのコードに追加します。そしてこの関数をbibilio関数として引き出し、Expert Advisorからパラメータを渡します。そうでしょう?

どんなインジケーターのソースコードでも、enclodeを介してExpert Advisorに接続させることができると思います。そして、それらを関数と同じように扱うことができる。

マクロやその他の特殊な部分を少しいじくる必要があります。この解決策ですべてのインジケータをカバーできるわけではない。しかし、ほとんどのインジケーターに対応できるはずです。

 

リカバリーを試みる

私なりの測定方法を掲載します。MACDサンプル 5の1つの値をExpert Advisorの基本バージョンとした。小さな変更が加えられた。すべてのインジケータの値が一箇所に集められているため、簡単なマクロ置換を行うことは難しくありませんでした:結論は明らかだと思います:MQL4モードでインジケータを呼び出すと、速度が40%低下します。

ファイル:
 
Yuriy Koptsev:


open-stopが設定され、その後、trawlがそれを引っ張ります。


ATR*0.5(ATR=80pp)のほぼすべてのロットで、どうして150pipsのストップを設定できるのでしょうか?このような設定では、ストップはロットの始値から 約40pips以上には決してならないはずです。そして、このレベルより上になったときだけ、それはすでにその上で取引されます。
ファイル:
 
読む機会がなかった。
 
更新された
 
 
Vasiliy Sokolov:

回復を試みる:

私の測定バージョンを掲載します。MACDサンプル 5の1つの値をExpert Advisorの基本バージョンとした。小さな変更を加えた。すべてのインジケータの値が一箇所に集められているため、簡単なマクロ置換を行うことは難しくありませんでした:結論は明らかだと思います:MQL4モードでインジケータを呼び出すと、速度が40%低下します。

投稿を復元(編集)することができます:

インジケータを呼び出すと、速度は40%遅くなります。


- MQL4モードでインジケータを呼び出すと、スピードが40%低下するという結論は明らかだと思います。