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

 
Alexey Viktorov:
新しいバーと一緒にヒストリーのサブローディングができないなんて、どこに書いてあるんだ?

履歴を追うべきと書かれているのはどこですか?
読み込み中は、インジケータの計算を 無視することができます - 完全な履歴がないため(バーはどこにでも表示されます)。
それゆえ、結論としては、すべてのバーを建設した後でなければ、新しいバーはできない。
そうでなければ、すべてのバーが「古い」のです。

 
m-r LSV:

役に立たなかった :(

コードを表示する

 
Taras Slobodyanik:

自分が作ったものを見てほしい。

タラス!!!あの人がMQL5について聞いている!!!そして、MT5は左から右へインデックスされている・・・1バーを数えるのではなく、rates_total-2を数えることが判明。

 
Taras Slobodyanik:

履歴の読み込みを監視しなければならないとは、どこに書いてあるのですか?
読み込み中は、完全な履歴がないため、指標の計算を 無視することができます。
だから、すべてのバーを作り終えてから、新しいバーを作るという結論になる。
それ以外はすべて "古い "バーです。

履歴のある方法をアドバイスしてください。
もちろん、履歴で何かを確認することは予定しています。
いくつか観察したところ、矢印にバッファを使いたい。

しかし、それは後の祭りです。

 
Taras Slobodyanik:

コードを表示する

//+------------------------------------------------------------------+
//|                                                    test.mq5 |
//|                                  Copyright 2021, MetaQuotes Ltd. |
//|                                             https://www.mql5.com |
//+------------------------------------------------------------------+
#property copyright "Copyright 2021, MetaQuotes Ltd."
#property link      "https://www.mql5.com"
#property version   "1.00"
#property indicator_chart_window

#property indicator_buffers 2
#property indicator_plots   2

#property indicator_label1  "Signal UP"
#property indicator_type1   DRAW_ARROW
#property indicator_color1  clrLime
#property indicator_style1  STYLE_SOLID
#property indicator_width1  2

#property indicator_label2  "Signal DN"
#property indicator_type2   DRAW_ARROW
#property indicator_color2  clrRed
#property indicator_style2  STYLE_SOLID
#property indicator_width2  2

double up[];
double dn[];

datetime fin=0, last=0;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
    IndicatorSetString(INDICATOR_SHORTNAME, "Prototype");
    
   SetIndexBuffer(0,up,INDICATOR_DATA);
   PlotIndexSetInteger(0,PLOT_ARROW,233);
    
   SetIndexBuffer(1,dn,INDICATOR_DATA);
   PlotIndexSetInteger(1,PLOT_ARROW,234);
   
   
  
   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[])
   {
   fin=iTime(Symbol(), PERIOD_M1 ,0);
   if(last==fin) return(rates_total);
   last=fin;
   
   if(rates_total - prev_calculated == 1)
      {
      //Print("Новый бар");
      if(open[1] > close[1])
           {
           Print("Dn");
           }
      else if(open[1] < close[1])
           {
           Print("Up");
           }
      }

return(rates_total);
}
 
Alexey Viktorov:

タラス!!!あの人がMQL5について聞いている!!!MT5では、インデックスは左から右へ・・・1バーではなく、rates_total-2をカウントしなければならないことが判明しました。

いやいや、prev_calculated と rates_total は依存しない。

 
Taras Slobodyanik:

no-no、prev_calculated と rates_total はこれに依存しない。

prev_calculatedとrates_totalは、左の最初のバーの開閉を読むことを提案していますが、どのような関係があるのでしょうか。

 
Alexey Viktorov:

prev_calculatedとrates_totalは、左の最初のバーの開始と終了を読むことを提案していますが、どのような関係があるのでしょうか。

左側のクローズドバーを読めとは言っていない、これは私のコードではない)

吾唯足知

if(rates_total - prev_calculated == 1)
 
m-r LSV:

役に立たなかった :(

はい、配列の方向を変更するか、1ではなくrates_total-2の インデックスを取る必要があります。

{
   
   ArraySetAsSeries(open,true);
   ArraySetAsSeries(high,true);
   ArraySetAsSeries(low,true);
   ArraySetAsSeries(close,true);
   ArraySetAsSeries(time,true);
   
   if(rates_total - prev_calculated > 1)
      {
      Print("Загрузка истории");
      return(rates_total);
      }
   
   if(rates_total - prev_calculated == 1)
      {
      //Print("Новый бар");
      if(open[1] > close[1])
           {
           Print("Dn");
           }
      else if(open[1] < close[1])
           {
           Print("Up");
           }
      }

return(rates_total);
}


 
Taras Slobodyanik:

左のバークローズを読めとは言っていない、それは私のコードではない)

私のだけです。

あからさまな嘘をつくのは見苦しい。自分の投稿を削除して、自分の無教養を他人のせいにするんですね。嘘つけ。