無料でロボットをダウンロードする方法を見る
Facebook上で私たちを見つけてください。
私たちのファンページに参加してください
興味深いスクリプト?
それではリンクにそれを投稿してください。-
他の人にそれを評価してもらいます
記事を気に入りましたか?MetaTrader 5ターミナルの中でそれを試してみてください。
エキスパート

MQL5 Wizard - ストキャスティクスによる条件付きのロウソク足の転換パターン - MetaTrader 5のためのエキスパート

ビュー:
1026
評価:
(44)
パブリッシュ済み:
2015.11.26 10:50
アップデート済み:
2016.11.22 07:34
\MQL5\Include\Expert\Signal\MySignals\
このコードに基づいたロボットまたはインジケーターが必要なら、フリーランスでご注文ください フリーランスに移動

詳細:

MQL5 Wizardを使えば、トレードシグナルやポジション追跡や資金管理などの条件に基づいたEAのコードを自動的に生成することができます。標準ライブラリのトレードシグナルのクラスを使えば、トレード手法を開発し検証することが可能です。そのためには、トレードシグナルのモジュールを書きます。

書籍 "The Strategies of the Best Traders in the World" (ロシア)には、MetaStockソフトパッケージを含む、テクニカル分析におけるインジケーターとトレード手法が記載されています。汎用的なトレードシグナルとして、その書籍は足の転換パターンとStochastic, CCI, MFI and RSI</a4などの組み合わせに基づいた手法を扱っています。

足の"反転"パターンとオシレーターのシグナルを組みまわせて使うと、ダマシの数を減らし、トレードシステムをより良いものにしてくれます。

前回では、足の転換パターンとStochasticによるシグナルを考察しました:

  1. 3 Black Crows/3 White Soldiers
  2. Dark Cloud Cover/Piercing Line
  3. Bullish Engulfing/Bearish Engulfing
  4. Bullish Harami/Bearish Harami
  5. Hammer/Hanging Man
  6. Bullish/Bearish Meeting Lines
  7. Morning/Evening Stars

今回は、これらのモデルとStochasticを組み合わせた結果を考察します。


1. Bullish and Bearish Candlestick Models と その検出

CandlePattern クラスには、ブル型・ベア型の足パターンの形を検出する関数があります。 (Hammer/Hanging Man の組み合わせ以外).

ベア型の足パターンの形成は CheckPatternAllBullish() で確認できます:

//+------------------------------------------------------------------+
//| Checks formation of bullish patterns                             |
//+------------------------------------------------------------------+
bool CCandlePattern::CheckPatternAllBullish()
  {
   return(CheckPatternThreeWhiteSoldiers()  || 
          CheckPatternPiercingLine()       || 
          CheckPatternMorningDoji()        || 
          CheckPatternBullishEngulfing()   || 
          CheckPatternBullishHarami()      || 
          CheckPatternMorningStar()        || 
          CheckPatternBullishMeetingLines());
  }

ブル型の足パターンの形成は CheckPatternAllBearish() で確認できます:

//+------------------------------------------------------------------+
//| Checks formation of bearish patterns                             |
//+------------------------------------------------------------------+
bool CCandlePattern::CheckPatternAllBearish()
  {
   return(CheckPatternThreeBlackCrows()     || 
          CheckPatternDarkCloudCover()     || 
          CheckPatternEveningDoji()        || 
          CheckPatternBearishEngulfing()   || 
          CheckPatternBearishHarami()      || 
          CheckPatternEveningStar()        || 
          CheckPatternBearishMeetingLines());
  }

2. ストキャスティクスとの組み合わせによるトレードシグナル

新規ポジションのエントリーは、ブル型・ベア型のモデルが形成されStochastic oscillatorの条件が整ったときに、実行されます。%D シグナルラインは、基準値 (30 か 70)よりも上か下になければなりません。

決済のシグナルには2通りあります:

  1. 逆の足パターンが形成されたとき(買いポジションでベア型、売りポジションでブル型).
  2. %Dのその後の挙動によるもの%Dが逆の基準値に達した場合(買いポジションで80、売りポジションで20)、もしくは、%Dが逆のシグナルを確認できず、かつ、基準値(買いポジションは20、売りポジションは80)

エントリーと決済条件の確認は、下記のメソッドで行われます:

  • int CCP_Stoch::LongCondition() - 買いポジションのエントリー条件(m_pattern_0)と売りポジションの決済 (m_pattern_1)の確認;
  • int CCP_Stoch::ShortCondition() - 売りポジションのエントリー条件 (m_pattern_0) と買いポジションの決済(m_pattern_1)の確認

2.1. 買いポジションのエントリーと売りポジションの決済

  1. 買いポジションのエントリーシグナルはブル型の足の形成と StochSignal(1)<30 (ひとつ前の確定足のStochasticのシグナルラインが30未満)の条件で行われます。

  2. 売りポジションの決済シグナルは、ブル型の足の形成か、インジケータのラインがStochasticの20か80を上抜けした場合です。

//+------------------------------------------------------------------+
//| Method of checking if the market models are formed               |
//| Checks conditions for                                            |
//| entry (open short position, m_pattern_0)                         |
//| exit  (close long position, m_pattern_1)                         |
//+------------------------------------------------------------------+
int CCP_Stoch::LongCondition()
  {
   int res=0;
//---- check conditions to open short position
//---- formation of bullish pattern and signal line of Stochastic indicator<30 
   if(CheckPatternAllBullish() && (StochSignal(1)<30)) res=m_pattern_0; // signal to open long position 

//--- check conditions of short position closing
//--- formation of bearish pattern or crossover of the signal line (upward 20, upward 80)
   if(CheckPatternAllBullish() ||
      ((StochSignal(1)>20) && (StochSignal(2)<20)) || 
      ((StochSignal(1)>80) && (StochSignal(2)<80)))    res=m_pattern_1; // signal to close short position
//---
   return(res);
  }

2.2. 売りポジションのエントリーと買いポジションの決済

  1. 売りポジションのエントリーシグナルはベア型の足の形成と StochSignal(1)>70 (ひとつ前の確定足のStochasticのシグナルラインが70以上)の条件で行われます。

  2. 買いポジションの決済シグナルは、ベア型の足の形成か、インジケータのラインがStochasticの20か80を下抜けした場合です。

//+------------------------------------------------------------------+
//| Method of checking if the market models are formed               |
//| Checks conditions for                                            | 
//| entry (open short position, m_pattern_0)                         |
//| exit  (close long position, m_pattern_1)                         |
//+------------------------------------------------------------------+
int CCP_Stoch::ShortCondition()
  {
   int res=0;
//--- check conditions to open short position
//---- formation of bearish pattern and signal line of Stochastic indicator>70
   if(CheckPatternAllBearish() && (StochSignal(1)>70)) res=m_pattern_0; // signal to open short position 

//--- check conditions of long position closing 
//---- formation of bearish pattern or crossover of the signal line (downward 80, downward 20)
   if(CheckPatternAllBearish() || 
      ((StochSignal(1)<80) && (StochSignal(2)>80)) || 
      ((StochSignal(1)<20) && (StochSignal(2)>20)))    res=m_pattern_1; // signal to close long position 
//---
   return(res);
  }

2.3. MQL5 Wizard を使って、"Candlestick Patterns+Stochastic"のトレードシグナルに基づいたEAを生成

CCP_Stoch は標準ライブラリには含まれていません。そのため、ccp_stoch.mqh (添付)をダウンロードして、\terminal_folder\Include\Expert\Signal\MySignals に保存する必要があります。candlepatterns.mqh をコピーしてccp_stoch.mqhと同じディレクトリに保存してください。 . その後、MQL5 Wizardでファイルを使うにはMetaEditor を再起動してください。

MQL5 Wizardでこのトレード手法のトレードロボットを作るには、次のステップとして"Signals based on Candlestick Patterns+Stochastic"を選択してください:

図1. MQL5 Wizard の "Signals based on Candlestick Patterns+Stochastic"を選択してください。

図1. MQL5 Wizard の "Signals based on Candlestick Patterns+Stochastic"を選択してください。

次のステップは、trailing stopのタイプとmoney managementを選択してください。EAのコードが自動的に生成されます。次にコンパイルすればテストすることができます。


2.4. テスト結果

過去データにおけるEAのバックテスト結果 (EURUSD H1, テスト期間: 1.1.2000-02.02.2011, PeriodK=33, PeriodD=37, PeriodSlow=30, MA_period=25).

このEAは0.1ロット単位で修正するモジュールを使います。 (Trading Fixed Lot). Trailing stop は不使用 (Trailing 不使用).

図2. "Signals based on Candlestick Patterns+Stochastic"のEAのテスト結果

Fig. 2. "Signals based on Candlestick Patterns+Stochastic"のEAのテスト結果

パラメータの最適な値はMetaTrader 5 のStrategy Testerで探索できます。

MQL5 Wizard で生成したコードはexpert_cp_stoch.mq5です。

MetaQuotes Ltdによってロシア語から翻訳されました。
元のコード: https://www.mql5.com/ru/code/327

MQL5 Wizard - RSIの条件付きの Morning/Evening Stars MQL5 Wizard - RSIの条件付きの Morning/Evening Stars

RSIによる条件付きの"Morning Star/Evening Star"のシグナルを試すことができます。この戦略のエキスパートのコードは、MQL5ウィザードで自動生成させることができます。

MQL5 Wizard - MFIの条件付きの Morning/Evening Stars MQL5 Wizard - MFIの条件付きの Morning/Evening Stars

MFIによる条件付きの"Morning Star/Evening Star"のシグナルを試すことができます。この戦略のエキスパートのコードは、MQL5ウィザードで自動生成させることができます。

DRAW_LINE DRAW_LINE

DRAW_LINEの描写スタイルは、インジケーターのバッファの値を線としてプロットする際に使われます。

DRAW_SECTION DRAW_SECTION

DRAW_SECTIONの描写スタイルは、インジケーターの値をセクションとして描写する際に使われます。