MQL4、MQL5に関する初心者からの質問、アルゴリズムやコードに関するヘルプ、ディスカッションなど。 - ページ 232

 
Rustam Bikbulatov:
2番目。注文を開くためのコマンド

意味がないんです。成行注文とどう関係があるのですか?もしかして、インジケーターの呼び出しの せい?次に、インジケータを修正し、iMACDの代わりにiCustomを使用して呼び出します。

多分、何も改造する必要は全くなく、kodobaseが充実しているのでしょう。

 
Vitalie Postolache:

意味がないんです。成行注文とどう関係があるのですか?もしかして、インジケーターの呼び出しの せい?次に、インジケータを修正し、iMACDの代わりにiCustomを使用して呼び出します。

多分、私は何も修正する必要はないでしょう、Kodobaseは良いものばかりです。


iCustom経由で試しましたが、動作が遅いです。iMAOnArray 経由で試しましたが、配列に問題が ありました。すべてのアレイを束ねるのに、2、3日かかりました。 iMACDを作るのは簡単 だが、それが問題だ

 
Rustam Bikbulatov:

iCustomを試しましたが、動作が遅いです。iMAOnArrayを試したが、配列に問題が ある。数日間、すべてを束ねることができなかった。iMACDの 方が 作り やすいのですが、そこが問題 です。


標準のiMACDはSMAの計算式を使ってシグナルラインを 計算するので、カスタムだけが役に立ちます。

 
Vitalie Postolache:

まさか、標準のiMACDはSMAの計算式でシグナルラインを 計算しているので、カスタムでしか役に立ちません。


OK、それは無理だと分かりました。情報をどうもありがとうございました。

 
Rustam Bikbulatov:

無理だと悟りました。 情報をどうもありがとうございました。


不可能なことはない、ただ少し範囲を広げればいいだけだ )))

 
Rustam Bikbulatov:

そうなんだ、そんなことあるんだ。

以下は、標準的なMACDのコードです。

//+------------------------------------------------------------------+
//|                                                  Custom MACD.mq4 |
//|                   Copyright 2005-2014, MetaQuotes Software Corp. |
//|                                              http://www.mql4.com |
//+------------------------------------------------------------------+
#property copyright   "2005-2014, MetaQuotes Software Corp."
#property link        "http://www.mql4.com"
#property description "Moving Averages Convergence/Divergence"
#property strict

#include <MovingAverages.mqh>

//--- indicator settings
#property  indicator_separate_window
#property  indicator_buffers 2
#property   indicator_color1  Silver
#property   indicator_color2  Red
#property   indicator_width1  2
//--- indicator parameters
input int InpFastEMA=12;   // Fast EMA Period
input int InpSlowEMA=26;   // Slow EMA Period
input int InpSignalSMA=9;  // Signal SMA Period
//--- indicator buffers
double    ExtMacdBuffer[];
double    ExtSignalBuffer[];
//--- right input parameters flag
bool      ExtParameters=false;

//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit(void)
  {
   IndicatorDigits(Digits+1);
//--- drawing settings
   SetIndexStyle(0,DRAW_HISTOGRAM);
   SetIndexStyle(1,DRAW_LINE);
   SetIndexDrawBegin(1,InpSignalSMA);
//--- indicator buffers mapping
   SetIndexBuffer(0,ExtMacdBuffer);
   SetIndexBuffer(1,ExtSignalBuffer);
//--- name for DataWindow and indicator subwindow label
   IndicatorShortName("MACD("+IntegerToString(InpFastEMA)+","+IntegerToString(InpSlowEMA)+","+IntegerToString(InpSignalSMA)+")");
   SetIndexLabel(0,"MACD");
   SetIndexLabel(1,"Signal");
//--- check for input parameters
   if(InpFastEMA<=1 || InpSlowEMA<=1 || InpSignalSMA<=1 || InpFastEMA>=InpSlowEMA)
     {
      Print("Wrong input parameters");
      ExtParameters=false;
      return(INIT_FAILED);
     }
   else
      ExtParameters=true;
//--- initialization done
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Moving Averages Convergence/Divergence                           |
//+------------------------------------------------------------------+
int OnCalculate (const int rates_total,
                 const int prev_calculated,
                 const datetime& time[],
                 const double& open[],
                 const double& high[],
                 const double& low[],
                 const double& close[],
                 const long& tick_volume[],
                 const long& volume[],
                 const int& spread[])
  {
   int i,limit;
//---
   if(rates_total<=InpSignalSMA || !ExtParameters)
      return(0);
//--- last counted bar will be recounted
   limit=rates_total-prev_calculated;
   if(prev_calculated>0)
      limit++;
//--- macd counted in the 1-st buffer
   for(i=0; i<limit; i++)
      ExtMacdBuffer[i]=iMA(NULL,0,InpFastEMA,0,MODE_EMA,PRICE_CLOSE,i)-
                    iMA(NULL,0,InpSlowEMA,0,MODE_EMA,PRICE_CLOSE,i);
//--- signal line counted in the 2-nd buffer
   SimpleMAOnBuffer(rates_total,prev_calculated,0,InpSignalSMA,ExtMacdBuffer,ExtSignalBuffer);
   //ExponentialMAOnBuffer(rates_total,prev_calculated,0,InpSignalSMA,ExtMacdBuffer,ExtSignalBuffer);
//--- done
   return(rates_total);
  }
//+------------------------------------------------------------------+

ピンクで示した 線は私が追加したものです。

ピンクで表示されている線をコメントアウトし緑で表示されている線をコメントアウト すると、MACDはすべて指数 MACDで計算されるはずです。

 
Artyom Trishkin:

以下は、標準的なMACDのコードです。

ピンクで示した 線は私が追加したものです。

ピンクと書かれた線のコメントを解除 し、緑と書かれた線をコメントアウト すると、MACDはすべて指数MACDで計算されるはずです。


問題は、それをEAでどうやるかだった。EAが自動的にSMAの計算式を使って 計算します。

 
Rustam Bikbulatov:

問題は、これをEAでどうやるかだった。EAが自動的に 計算するSMAは、以下の式で算出されます。

カスタムMACDの作り方を紹介しました。

これは、iCustom()を通してExpert Advisorで使用するものです。

 
Artyom Trishkin:

カスタムMACDの作り方を紹介しました。

これは、iCustom()を介してExpert Advisorで使用するものです。


データ量が多くてブッシュが遅くなる。もう試しましたよ。結果に影響を与える。とにかくありがとうございます。

 
Rustam Bikbulatov:

データ量が多く、ブッシュが遅くなる。もう試しましたよ。結果に影響を及ぼしています。こちらこそ、ありがとうございました。

設定を確認してください。表示するバーの数が多すぎるため、遅延が発生している可能性があります。