TFを変更するのは問題 - ページ 5

 

これが指標になります。

//+------------------------------------------------------------------+
//|                                                    Shabl_ind.mq4 |
//|                                      Copyright 2012, CompanyName |
//|                                       http://www.companyname.net |
//+------------------------------------------------------------------+
#property copyright "eevviill"
#property link      "http://alievtm.blogspot.com"
#property version   "1.42"
#property strict
#property indicator_chart_window
#property indicator_buffers 2
#property  indicator_color1 clrLightBlue
#property  indicator_color2 clrRed
#property  indicator_width1 2
#property  indicator_width2 2

input string   arr_set="Arrow settings";
input int      arrow_indent=22;
input int      up_arrow_code=233;
input int      down_arrow_code=234;

double         up_arr[];
double         down_arr[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   SetIndexBuffer(0,up_arr);
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,up_arrow_code);
   SetIndexLabel(0,"UP arrow");

   SetIndexBuffer(1,down_arr);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,down_arrow_code);
   SetIndexLabel(1,"DOWN arrow");

   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Shabl_ind                                                        |
//+------------------------------------------------------------------+
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=0;
//---
   if(rates_total<=20)
      return(0);
//--- last counted bar will be recounted
   if(prev_calculated==0)
      limit=rates_total-1;
   if(prev_calculated>0)
      limit=rates_total-prev_calculated+1;
   Comment("rates_total=",rates_total,"; prev_calculated=",prev_calculated,"; limit=",limit);
//--- Shabl_ind counted in the 1-st buffer
   datetime temp;
   for(i=0; i<limit; i++)
     {
      temp=time[i];
      if(close[i]>close[i+1])
         up_arr[i]=low[i]-arrow_indent*Point; //up arrow
      if(close[i]<close[i+1])
         down_arr[i]=high[i]+arrow_indent*Point; //down arrow
     }
   return(rates_total);
  }
//+------------------------------------------------------------------+

ただし、条件によっては、インジケータがゼロ・バーで両方のバッファを描画する場合があることに注意してください。

ファイル:
 
Karputov Vladimir:

これが指標になります。

お客様の条件によっては、インジケーターが両方のバッファーをゼロバーで描画 する場合がありますので、ご注意ください。

2つのバッファを描画しないようにするため、一方のバッファが満杯になったときにもう一方のバッファをゼロにする必要があります

      if(close[i]>close[i+1])
       {
        down_arr[i] = EMPTY_VALUE;
        up_arr[i]=low[i]-arrow_indent*Point; //up arrow
       }
      if(close[i]<close[i+1])
       {
        up_arr[i] = EMPTY_VALUE;
        down_arr[i]=high[i]+arrow_indent*Point; //down arrow
       }
 
Vasyl Nosal:
ソリューションコードはありますか?

他の多くの人と同じように、あなたの質問に対する解答は一つではありません。なぜなら、指標はニュアンス(行う作業/コード/計算間隔など、一般的に多くの要素)が異なることがあるからです。

 
Karputov Vladimir:

これが指標になります。

ただ、あなたの条件に従って、インジケータはゼロバーで両方のバッファを描画することができることに注意してください。

皆さんは私をバカにしているのか、それとも本当に何が問題なのか分からないのでしょうか?

未搭載のヒストリーでTFを変更した場合のインジケータはこちらです。

 
Dina Paches:

他の多くの人と同じように、あなたの質問に対する解答は一つではありません。なぜなら、指標はニュアンス(行う作業/コード/計算間隔など、一般的に多くの要素)が異なることがあるからです。

ボソボソ...。
 
Vasyl Nosal:

皆さんは、私をからかっているのか、それとも本当に問題が何なのか、全くわかっていないのか?

アンロード履歴でのTF変化のインジケータはこちらです。

このような面白い写真を撮るために、どのような操作をしているのか教えてください。そして、今後はもっと遠慮してほしい。

追記:上記で、ヒストリーを汲み上げる際に、インジケータバッファの内容を自分で考える必要があると書きました。

トレーディング、自動売買システム、トレーディング戦略のテストに関するフォーラム

TFを変更することは問題である

カルプトフ ウラジミール さん 2015.12.07 10:09

prev_calculatedとrates_totalという2つの変数を自由に使うことができます。ヒストリーロードをコントロールする(prev_calculated==0とする)ことで、インジケータバッファをどうするか考えなければなりません。このような場合の通常の動作は、ヒストリーロードを最初のインジケータロードイベントと 同一にすることです。

しかし、あなたはなぜかそれを無視し、編集をしたがらなかった。

とにかく、ここにバージョン1.43があります(ここに私の修正とAlexey Viktorovの 修正があります)。

トレーディング、自動売買システム、ストラテジーテスターに関するフォーラム

TFの変化 - 問題

アレクセイ・ビクトロフ さん 2015.12.07 12:52

2つのバッファを描画しないようにするには、1つのバッファが満杯になったときに0にリセットする必要があります。

      if(close[i]>close[i+1])
       {
        down_arr[i] = EMPTY_VALUE;
        up_arr[i]=low[i]-arrow_indent*Point; //up arrow
       }
      if(close[i]<close[i+1])
       {
        up_arr[i] = EMPTY_VALUE;
        down_arr[i]=high[i]+arrow_indent*Point; //down arrow
       }

:

//+------------------------------------------------------------------+
//|                                                    Shabl_ind.mq4 |
//|                                      Copyright 2012, CompanyName |
//|                                       http://www.companyname.net |
//+------------------------------------------------------------------+
#property copyright "eevviill"
#property link      "http://alievtm.blogspot.com"
#property version   "1.43"
#property strict
#property indicator_chart_window
#property indicator_buffers 2
#property  indicator_color1 clrLightBlue
#property  indicator_color2 clrRed
#property  indicator_width1 2
#property  indicator_width2 2

input string   arr_set="Arrow settings";
input int      arrow_indent=22;
input int      up_arrow_code=233;
input int      down_arrow_code=234;

double         up_arr[];
double         down_arr[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   SetIndexBuffer(0,up_arr);
   SetIndexStyle(0,DRAW_ARROW);
   SetIndexArrow(0,up_arrow_code);
   SetIndexLabel(0,"UP arrow");

   SetIndexBuffer(1,down_arr);
   SetIndexStyle(1,DRAW_ARROW);
   SetIndexArrow(1,down_arrow_code);
   SetIndexLabel(1,"DOWN arrow");

   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Shabl_ind                                                        |
//+------------------------------------------------------------------+
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=0;
//---
   if(rates_total<=20)
      return(0);
//--- last counted bar will be recounted
   if(prev_calculated==0)
     {
      limit=rates_total-1;
      ArrayInitialize(up_arr,EMPTY_VALUE);
      ArrayInitialize(down_arr,EMPTY_VALUE);
     }
   if(prev_calculated>0)
      limit=rates_total-prev_calculated+1;
   Comment("rates_total=",rates_total,"; prev_calculated=",prev_calculated,"; limit=",limit);
//--- Shabl_ind counted in the 1-st buffer
   for(i=0; i<limit; i++)
     {
      if(close[i]>close[i+1])
        {
         down_arr[i]=EMPTY_VALUE;
         up_arr[i]=low[i]-arrow_indent*Point; //up arrow
        }
      if(close[i]<close[i+1])
        {
         up_arr[i]=EMPTY_VALUE;
         down_arr[i]=high[i]+arrow_indent*Point; //down arrow
        }
     }
   return(rates_total);
  }
//+------------------------------------------------------------------+
ファイル:
 
Karputov Vladimir:

このような面白い写真を撮るために、どのような操作をしているのか教えてください。そして、今後はもっと遠慮してほしい。

今まで開いたことのない通貨ペアのチャートを開いてみる。M1などです。インジケーターを添付します。M5に変更します。

では、私は正しかったのでしょうか?アローバッファをリセットする必要があるのでは?

 
Vasyl Nosal:

mql4

いや、歴史がないペアのデザインはこれだ。

THISとは?

if(i>Bars-20) i=Bars-20;

やはり、内部でループが根付いているのですね。また、ループの中では前のバー([i+1])にアクセスしているので、ヒストリーの2番目のバー(左から数えて)よりも早く計算を開始する必要があります。また、バッファは1本だけでなく、各バーALLで満たす必要があります。まあ、あるいはOnInit()であらかじめ初期化しておくか。

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 nStartBar = rates_total - MathMax(prev_calculated, 2);

   for(int i = nStartBar; i >= 0; i--)
   {
      if(Close[i] > Close[i+1])
      {
         up_arr[i] = Low[i] - arrow_indent * _Point; //up arrow
         down_arr[i] = 0;
      }
         
      if(Close[i] < Close[i+1])
      {
         up_arr[i] = 0;
         down_arr[i] = High[i] + arrow_indent * _Point; //down arrow
      }
   }

   return(rates_total);
}
 
Karputov Vladimir:

とにかく、これがバージョン1.43です(私の修正点とAlexey Viktorovの 修正点はこちら)。


:

ウラジミール、なぜOnCalculate()の中でこんなことをしているんだ?最後の2行、つまり配列の再初期化を意味しています。両方のバッファは各バーで計算されます、それは不必要な動作です。

if(prev_calculated==0)
{
   limit=rates_total-1;
   ArrayInitialize(up_arr,EMPTY_VALUE);
   ArrayInitialize(down_arr,EMPTY_VALUE);
}
 
Sergei Vladimirov:

これは何なんだ?

やはり、ループが内部で破損しているのでしょうか。また、ループ本体([i+1])で前のバーにアクセスする場合、計算はヒストリーの2番目のバー(左から数えて)よりも早く開始されるべきではありません。また、バッファは1本だけでなく、各バーALLで満たす必要があります。まあ、あるいはOnInit()であらかじめ初期化しておくか。

不具合はないのか?