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

 
prom18:

もしかしたら、例があるかもしれませんね。視覚的にわかりやすいと思います。ありがとうございます。

ある時間間隔のバーが必要だということが正しく理解できれば、iTimeを使って それらを選択することができます。
 
prom18:

こんにちは。教科書を読んでいるところです。インジケーターの書き方にはいくつかの例があります。 separatewindow.mq4の インジケーターについて質問です。 そこで計算棒の本数を設定することができます。当日の始値から(またはゼロから)終値までの計算を指定する必要がある場合はどうすればよいでしょうか。どうすればいいのでしょうか?解決策を検索してみたが、見つからなかった。

以下は、現在のタイムフレームにおける当日の始値です。

//+------------------------------------------------------------------+
//|                                                      DayOpen.mq4 |
//|                                            Copyright 2018, IgorM |
//|                              https://www.mql5.com/ru/users/igorm |
//+------------------------------------------------------------------+
#property copyright "Copyright 2019, IgorM"
#property link      "https://www.mql5.com/ru/users/igorm"
#property version   "1.00"
#property strict
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots   1
//--- plot Label1
#property indicator_label1  "Label1"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrRed
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- indicator buffers
double         Label1Buffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,Label1Buffer);
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
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;
   static double dayopen=0.0;
   static int lastday=0;
   if(prev_calculated==0)
     {
      limit=rates_total-1;
      dayopen=0.0;
      lastday=0;
     }
   else limit=rates_total-prev_calculated;
   for(i=limit; i>=0; i--)
     {
      if(TimeDay(time[i])!=lastday)
        {
         dayopen=open[i];
         lastday= TimeDay(time[i]);
        }
      Label1Buffer[i]=dayopen;
     }
   return(rates_total);
  }
 

こんにちは!履歴の中で指定したバーのRIGHTにある右のバーを条件によって見つけることは可能でしょうか? ありがとうございます。

 
Sfinks35:

こんにちは!履歴の中で指定したバーのRIGHTにある右のバーを条件によって見つけることは可能でしょうか? ありがとうございます。

はい、できます。

 
Artyom Trishkin:

できます。

どうやるんですか?教えてください。
 
Sfinks35:
どうやるんですか?教えていただけますか?

与えられたバーをどのように見つけるか?

 
Artyom Trishkin:

与えられたバーをどのように見つけるか?


時間はかかりましたが、こんな感じの関数を書きました。

double GetPatt5barsDN()
{
double low3 = 0;
int index = 0;
for(int i=1; i<20; i++)
{
もし
((Close[i]>Open[i])&&(Close[i])です。
(Close[i+1] > Open[i+1]) && (Close[i+1] > Open[i+1])
(Close[i+2] > Open[i+2]) && //このローソク足でLow[i+2]が必要です。
(Close[i+3] < Open[i+3]) && (Close[i+3] < Open[i+3])
(クローズ[i+4] < オープン[i+4])

Low3 = Low[i+2];
index = i+2 とする。
}

return(low3)です。
}

 
Igor Makanu:

現在のTFにおける当日の始値です。

イゴールさん、ありがとうございます。しかし、私はそれを正しく定式化できていません。指定したバー数(ここでは50本)のインジケータを計算し、別ウィンドウで描画します。MAを表示するには、始値ではなく、その日の最初のバーが必要です。でも、とにかく、ありがとうございました。

 
Igor Makanu:

現在のTFでの当日の始値はこちらです。

に書かれていることを教えてください。

int i,limit=prev_calculated==0 ?rates_total-1 : rates_total-prev_calculated;

"==" , "?", ": "

?

 
Sfinks35:


時間はかかりましたが、こんな感じの関数を書きました。

リンクで渡された関数パラメータ内のインデックスも返す