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

 
Rashid Umarov:

追記 USDJPY M30 2017.02.01-2018.01.18 "All ticks" (記事通り) MetaQuotes-Demoで標準のMACDサンプルを動かしてみました。

8秒に収まるのか?特に1秒で?

取引、自動取引システム、取引戦略のテストに関するフォーラム

記事 "トレーダーのためのライフハック:指標からファーストフードを調理する "の議論

fxsaber, 2018.01.26 11:06 AM.

何もしていません。そのまま実行。上記のログに再現するためのすべてのデータがあります。 あなたの結果は利益の面で私のものと完全に同じでなければなりません。また、パフォーマンスも大差ありません。

 
Rashid Umarov:
本当ですか?私が お金をもらって書いた記事に間違いや問題が見つかったと言うなら、必ずチェックしますよ。とりあえず、"しよう "はやめよう。あなたが恩着せがましく言っているように聞こえるから。
 
fxsaber:

配信からMACDを サンプルにしました。そして、残高のEUROはどこから来ているのでしょうか?

そして、テスト時間はまだあなたよりはるかに長いです。

2018.01.26 13:34:10.520 Core 1  authorized (agent build 1755)
2018.01.26 13:34:10.522 Tester  EURUSD,M1 (MetaQuotes-Demo): testing of Experts\Examples\MACD\MACD Sample.ex5 from 2017.09.01 00:00 to 2018.01.26 00:00

2018.01.26 13:34:16.792 Core 1  EURUSD,M1 (MetaQuotes-Demo): generating based on real ticks
2018.01.26 13:34:16.792 Core 1  EURUSD,M1: testing of Experts\Examples\MACD\MACD Sample.ex5 from 2017.09.01 00:00 to 2018.01.26 00:00 started with inputs:
2018.01.26 13:34:16.792 Core 1    InpLots=0.1
2018.01.26 13:34:16.792 Core 1    InpTakeProfit=50
2018.01.26 13:34:16.792 Core 1    InpTrailingStop=30
2018.01.26 13:34:16.792 Core 1    InpMACDOpenLevel=3
2018.01.26 13:34:16.792 Core 1    InpMACDCloseLevel=2
2018.01.26 13:34:16.792 Core 1    InpMATrendPeriod=26


2018.01.26 13:25:46.482 Core 1  final balance 10168.90 USD
2018.01.26 13:25:46.482 Core 1  EURUSD,M1: 9753093 ticks, 147480 bars generated. Environment synchronized in 0:00:02.610. 
Test passed in 0:00:19.062 (including ticks preprocessing 0:00:02.078).
2018.01.26 13:25:46.482 Core 1  EURUSD,M1: total time from login to stop testing 0:00:21.672 (including 0:00:02.610 for history data synchronization)
2018.01.26 13:25:46.482 Core 1  600 Mb memory used including 44 Mb of history data, 256 Mb of tick data
 

記事のタイムフレームで、EURUSD,M30とUSDJPY,M30で

MACD Sample One value at a time.mq5:

final balance 100180.01 USD
EURUSD,M30: 26390728 ticks, 12510 bars generated. Environment synchronized in 0:00:00.125. Test passed in 0:00:41.016 (including ticks preprocessing 0:00:02.328).
EURUSD,M30: total time from login to stop testing 0:00:41.141 (including 0:00:00.125 for history data synchronization)
756 Mb memory used including 1.88 Mb of history data, 512 Mb of tick data

final balance 99523.31 USD
USDJPY,M30: 29801706 ticks, 11837 bars generated. Environment synchronized in 0:00:00.032. Test passed in 0:01:00.937 (including ticks preprocessing 0:00:02.735).
USDJPY,M30: total time from login to stop testing 0:01:00.969 (including 0:00:00.032 for history data synchronization)
819 Mb memory used including 1.88 Mb of history data, 576 Mb of tick data


MACD Sample 4 to 5 MQL4 style.mq5:

final balance 100192.51 USD
EURUSD,M30: 26390728 ticks, 12510 bars generated. Environment synchronized in 0:00:00.140. Test passed in 0:01:37.969 (including ticks preprocessing 0:00:02.329).
EURUSD,M30: total time from login to stop testing 0:01:38.109 (including 0:00:00.140 for history data synchronization)
755 Mb memory used including 1.88 Mb of history data, 512 Mb of tick data

final balance 99550.10 USD
USDJPY,M30: 29801706 ticks, 11837 bars generated. Environment synchronized in 0:00:00.031. Test passed in 0:01:51.328 (including ticks preprocessing 0:00:02.500).
USDJPY,M30: total time from login to stop testing 0:01:51.359 (including 0:00:00.031 for history data synchronization)
819 Mb memory used including 1.88 Mb of history data, 576 Mb of tick data

テスト時間が2回異なる。しかも8秒でも1秒でもない。

残高を比較すると - はい、数字にわずかな違いがありますが、チャート上では目立ちません。

 
Vasiliy Sokolov:

実際、このトピックの説明は、ここでは少し違う次元で見られる:

  • 何千ものインジケーターがすでに書き込まれ、iCustom経由でアクセスされ、適切なバッファやハンドルが割り当てられるなどしている。これは時間がかかり、リソースを消費する話である;
  • この場合、必要な値はより速く計算され、より少ないメモリで済みます。

この場合、必要な値はより高速に計算され、より少ないメモリで済みます。このアイデアは、カスタム・インジケータに 統一的にアクセスできるようなインターフェースを書くことですが、インジケータが独立した純粋な関数として実装されている場合、ハンドルの代わりにこの関数が参照されます。 その結果、高速化を実現すると同時に、任意のインジケーターへのアクセスを失うこともありません。これは興味深いトピックだ。

やってみると面白い。インジケーターからOnCalculateを取り出し、新しい名前で少し修正し、インジケーターのコードに追加します。そうでしょう?
 
Rashid Umarov:
インジケーターからOnCalculateを取り出し、新しい名前で少し修正し、インジケーターのコードに追加する。そうでしょう?
あとは実装を考えましょう。さて、どのように実装するかは難しいところです。
 
Rashid Umarov:
やってみると面白いですよ。インジケーターからOnCalculateを取り出し、新しい名前で少し修正し、インジケーターのコードに追加します。そうでしょう?

私はこれをiRSIOnArray()のために行いました。インジケーターでは動作します。Expert Advisorから呼び出すには、そう単純にはいかない。

//+------------------------------------------------------------------+
//| 配列の相対力指数|
//+------------------------------------------------------------------+
template<typename T>
int RSIOnArray(const int rates_total,
               const int prev_calculated,
               const int begin,
               const int period,
               const T &price[],
               double &buffer_pos[],
               double &buffer_neg[],
               double &buffer_rsi[])
  {
   int   i;
   T     diff;
//--- レート数のチェック
   if(period<1 || rates_total-begin<period) return(0);
//--- as_seriesフラグを保存する
   bool as_series_price=ArrayGetAsSeries(price);
   bool as_series_rsi=ArrayGetAsSeries(buffer_rsi);
   if(as_series_price)
      ArraySetAsSeries(price,false);
   if(as_series_rsi)
     {
      ArraySetAsSeries(buffer_rsi,false);
      ArraySetAsSeries(buffer_pos,false);
      ArraySetAsSeries(buffer_neg,false);
     }
//--- 予備計算
   int pos=prev_calculated-1;
   if(pos<=period)
     {
      //--- インジケータの最初のRSIPeriod値は計算されない。
      buffer_rsi[0]=0.0;
      buffer_pos[0]=0.0;
      buffer_neg[0]=0.0;
      T SumP=0.0;
      T SumN=0.0;
      for(i=1; i<=period; i++)
        {
         buffer_rsi[i]=0.0;
         buffer_pos[i]=0.0;
         buffer_neg[i]=0.0;
         diff=price[i]-price[i-1];
         SumP+=(diff>0 ? diff : 0);
         SumN+=(diff<0 ?-diff : 0);
        }
      //--- 最初に見える値を計算する
      buffer_pos[period]=double(SumP/period);
      buffer_neg[period]=double(SumN/period);
      
      buffer_rsi[period]=100.0-(100.0/(1.0+buffer_pos[period]/(buffer_neg[period]>0 ? buffer_neg[period] : DBL_MIN)));
      //--- メイン計算のための位置値を準備する
      pos=period+1;
     }
//--- 計算のメインループ
   for(i=pos;i<rates_total && !IsStopped();i++)
     {
      diff=price[i]-price[i-1];
      buffer_pos[i]=(buffer_pos[i-1]*(period-1)+(diff>0.0 ? diff : 0.0))/period;
      buffer_neg[i]=(buffer_neg[i-1]*(period-1)+(diff<0.0 ?-diff : 0.0))/period;
      buffer_rsi[i]=100.0-100.0/(1+buffer_pos[i]/(buffer_neg[i]>0 ? buffer_neg[i] : DBL_MIN));
     }
//--- as_seriesフラグのリストア
   if(as_series_price) ArraySetAsSeries(price,true);
   if(as_series_rsi)
     {
      ArraySetAsSeries(buffer_rsi,true);
      ArraySetAsSeries(buffer_pos,true);
      ArraySetAsSeries(buffer_neg,true);
     }
//---
   return(rates_total);
  }
//+------------------------------------------------------------------+
 

取引、自動取引システム、取引戦略のテストに関するフォーラム

記事 "トレーダーのためのライフハック:指標からファーストフードを調理する "についての議論

ラシッド・ウマロフ, 2018.01.26 11:30 AM

MACD SaMpleを設定上の供給から作りました。EUROはどこからバランスしているのか、それはポイントではありませんか?

それはポイントではありません。ここからEUR


そして、テスト時間はまだあなたよりはるかに長いです。

2018.01.26 13:34:10.520 Core 1  authorized (agent build 1755)
2018.01.26 13:34:10.522 Tester  EURUSD,M1 (MetaQuotes-Demo): testing of Experts\Examples\MACD\MACD Sample.ex5 from 2017.09.01 00:00 to 2018.01.26 00:00

2018.01.26 13:34:16.792 Core 1  EURUSD,M1 (MetaQuotes-Demo): generating based on real ticks
2018.01.26 13:34:16.792 Core 1  EURUSD,M1: testing of Experts\Examples\MACD\MACD Sample.ex5 from 2017.09.01 00:00 to 2018.01.26 00:00 started with inputs:
2018.01.26 13:34:16.792 Core 1    InpLots=0.1
2018.01.26 13:34:16.792 Core 1    InpTakeProfit=50
2018.01.26 13:34:16.792 Core 1    InpTrailingStop=30
2018.01.26 13:34:16.792 Core 1    InpMACDOpenLevel=3
2018.01.26 13:34:16.792 Core 1    InpMACDCloseLevel=2
2018.01.26 13:34:16.792 Core 1    InpMATrendPeriod=26


2018.01.26 13:25:46.482 Core 1  final balance 10168.90 USD
2018.01.26 13:25:46.482 Core 1  EURUSD,M1: 9753093 ticks, 147480 bars generated. Environment synchronized in 0:00:02.610. 
Test passed in 0:00:19.062 (including ticks preprocessing 0:00:02.078).
2018.01.26 13:25:46.482 Core 1  EURUSD,M1: total time from login to stop testing 0:00:21.672 (including 0:00:02.610 for history data synchronization)
2018.01.26 13:25:46.482 Core 1  600 Mb memory used including 44 Mb of history data, 256 Mb of tick data

これがあなたの設定での私のログです。

EURUSD,M1 (MetaQuotes-Demo): generating based on real ticks
EURUSD,M1: testing of Experts\Examples\MACD\MACD Sample.ex5 from 2017.09.01 00:00 to 2018.01.26 00:00 started with inputs:
  InpLots=0.10
  InpTakeProfit=50
  InpTrailingStop=30
  InpMACDOpenLevel=3
  InpMACDCloseLevel=2
  InpMATrendPeriod=26

final balance 10000168.90 USD
EURUSD,M1: 9753093 ticks, 147480 bars generated. Environment synchronized in 0:00:00.031. Test passed in 0:00:06.302.
EURUSD,M1: total time from login to stop testing 0:00:06.333 (including 0:00:00.031 for history data synchronization)
571 Mb memory used including 44 Mb of history data, 256 Mb of tick data


なぜ私の場合は3.5倍も速いのか(バックテスト前に再コンパイルしてキャッシュを削除した) - 私にはわかりません。設定

2018.01.26 11:45:38.151 Terminal        Alpari Limited MT5 x64 build 1755 started (Alpari Limited)
2018.01.26 11:45:38.151 Terminal        Windows 7 Service Pack 1 (build 7601) x64, IE 9, Intel Core i7-2700 K  @ 3.50 GHz, Memory: 10147 / 16301 Mb, Disk: 3 / 29 Gb, GMT+2

理由を見つけましょう!これはとても重要だと思います。私はHDDを持っていない(SSDのみ)。それが問題なのかもしれません。でも、それだとMT5にとって非常にまずい。このコンポはとても古く、5年は確実に経っている。だから変なんだ。

 
Vladimir Karputov:

テスト時間は2倍違う。しかも8秒でも1秒でもない。

Terminalの起動 ログから設定行を表示する。

 
fxsaber:

なぜ実行速度が3.5倍も速くなったのか(バックテスト前に再コンパイルすることでキャッシュが除去された)、それは分からない。コンフィギュレーション

その理由を探ってみよう!これはとても重要なことだと思う。私はHDDを持っていない(SSDのみ)。それが問題なのかもしれません。でも、それだとMT5にとって非常にまずい。コンプはとても古く、5年は確実に経っている。だから変なんだ。

これが私のコンピュター、SSDなし

MetaTrader 5 x64 build 1755 started (MetaQuotes Software Corp.)
Windows 10 (build 16299) x64, IE 11, UAC, Intel Core i7  920 @ 2.67 GHz, Memory: 6613 / 12277 Mb, Disk: 156 / 270 Gb, GMT+3

すべての投稿を見たが、ティックの数は同じだ。

2018.01.26 13:25:46.482 Core 1  final balance 10168.90 USD
2018.01.26 13:25:46.482 Core 1  EURUSD,M1: 9753093  ticks, 147480 bars generated. Environment synchronized in 0:00:02.610. 
Test passed in 0:00:19.062 (including ticks preprocessing 0:00:02.078).
2018.01.26 13:25:46.482 Core 1  EURUSD,M1: total time from login to stop testing 0:00:21.672 (including 0:00:02.610 for history data synchronization)
2018.01.26 13:25:46.482 Core 1  600 Mb memory used including 44 Mb of history data, 256 Mb of tick data