エラー、バグ、質問 - ページ 1030

 
Al_key:

あと、コンポジットライブラリを使ってバーシフトが出るようになりました。メタトレーダーに内蔵されているツールはないのですか?

MT4のiBarShift() は、おそらくコンパイラ・ライブラリと同じように動作しますが、ビルトインにしたほうが高速に動作します(C++なので)。
 
MetaDriver:

あなたのケースは、小さなスリップで処理されます。

私のはもっとひどいです(ちなみにSlipのないケースは以前は使えていたのですが、数週間前にやめました)。

同じスキームが他の(現在ではない)チャートでクリープスリップ なしに動作しなくなった。

コードはこちらからhttps://www.mql5.com/ru/code/224

インストールされたフクロウ、参照。

現在のものでは、標準を投げています。チャート上のAMA、ポークの再計算(0から2350までのSleep時) - 私はM1にドロップし、戻ってくることはありません。数秒後AMAが表示される、それだけです。

フラグを使うようにしています(currentとm1の2つのフラグを格納したい場合? すでにcurrentの方(フラグ)を使っていて、今m1(フラグ2)を使っている場合、...)です。

が、どうでしょう。月曜日のティックは今のものに戻る前に来るだろう :)

update はい、チャート上に100個のオブジェクトがあり、さらにAMA、つまり、とても重いのです。

 
MetaDriver:

"そうしなければならない" フェディアそうしなければならないのです。

(c)シュリク

--

このようなエラーは、例えばダイナミックバッファ用のメモリが確保されていない場合(この場合はActualBufferの 下)に発生します。 このコード断片では明確ではありません。

これです。

また、ダイナミックバッファのメモリ確保はどのように行うのですか?

それが分かれば、疑問は消えるのでしょうね。

以下は、すべてのコードです。

#include <TimeSeries.mqh>

#property indicator_separate_window
#property indicator_buffers 3
#property indicator_plots   3
//--- plot Actual
#property  indicator_label1  "Actual"
#property  indicator_type1   DRAW_LINE
#property  indicator_color1  clrLime
#property  indicator_style1  STYLE_SOLID
#property  indicator_width1  1
//--- plot Consensus
#property  indicator_label2  "Consensus"
#property  indicator_type2   DRAW_LINE
#property  indicator_color2  clrPeachPuff
#property  indicator_style2  STYLE_SOLID
#property  indicator_width2  1
//--- plot Previous
#property  indicator_label3  "Previous"
#property  indicator_type3   DRAW_LINE
#property  indicator_color3  clrLightCyan
#property  indicator_style3  STYLE_SOLID
#property  indicator_width3  1
//--- indicator buffers
double         ActualBuffer[];
double         ConsensusBuffer[];
double         PreviousBuffer[];
//--- indicator vars
string sDatetime;
string sActual;
string sConsensus;
string sPrevious;
int file_handle;
int barshift;
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,ActualBuffer,INDICATOR_DATA);
   SetIndexBuffer(1,ConsensusBuffer,INDICATOR_DATA);
   SetIndexBuffer(2,PreviousBuffer,INDICATOR_DATA);
   file_handle = FileOpen("CSV - макроэкономика и госкорпстат/Existing Home Sales Change.csv",FILE_READ|FILE_CSV|FILE_ANSI,',');
   while(!FileIsEnding(file_handle))
        {
         sDatetime  = FileReadString(file_handle);
         sActual    = FileReadString(file_handle);
         sConsensus = FileReadString(file_handle);
         sPrevious  = FileReadString(file_handle);
         
         barshift = iBarShift(Symbol(), Period(), datetime(formatdatetime(sDatetime)), false);
         if(StringToDouble(formatstring(sActual)) > 0 && StringToDouble(formatstring(sActual)) < 10000) ActualBuffer[barshift] = StringToDouble(formatstring(sActual));
         Print(formatdatetime(sDatetime));
         Print("iBarShift = ", barshift, " Datetime = ", formatstring(sDatetime), " sActual = ", sActual, " sConsensus = ", sConsensus, " sPrevious = ", sPrevious);
        }
    
//---
   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[])
  {
//---
   
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
//| TradeTransaction function                                        |
//+------------------------------------------------------------------+
void OnTradeTransaction(const MqlTradeTransaction& trans,
                        const MqlTradeRequest& request,
                        const MqlTradeResult& result)
  {
//---
   
  }
//+------------------------------------------------------------------+
//| ChartEvent function                                              |
//+------------------------------------------------------------------+
void OnChartEvent(const int id,
                  const long &lparam,
                  const double &dparam,
                  const string &sparam)
  {
//---
   
  }
//+------------------------------------------------------------------+
//--- Функции форматирования
string formatstring(string strparam)
   {
      string result = StringSubstr(strparam,1, StringLen(strparam) - 2);
      return(result);
   }
string formatdatetime(string strparam)
   {
      string result = StringSubstr(strparam, 1, 4) + "." + StringSubstr(strparam, 5, 2) + "." + StringSubstr(strparam, 7, 11);
      
      return(result);
   }
 
Al_key:

これです。

ダイナミックバッファのメモリ確保はどのように行うのですか?

それが分かれば、疑問は消えるのでしょう。

以下は、すべてのコードです。

Ps.

そこでArray Resizeについて読んだのですが...以下はコピーです。

"リンク後の動的配列 buffer[] は、リンク先の配列があらかじめ 系列のインデックスを持つように設定されていたとしても、通常の配列と同様にインデックスを持つ ようになります。インジケータ配列の要素へのアクセス順序を変更したい場合は、SetIndexBuffer()関数で配列をバインドした後にArraySetAsSeries() 関数を適用する必要があります。SetIndexBuffer()関数で指標バッファとして割り当てられた動的配列は、サイズを変更してはならないことに留意する必要があります。 インジケータ・バッファの場合、すべてのリサイズ操作は端末の実行サブシステムによって行われる。"

混乱しています。

 
Silent:
設定したプロファイルをデフォルトに保存する File - Profiles - Default
Kind of default, still no data to load.数時間後に初めてすべてが終わった。
 
Al_key:

これです。

ダイナミックバッファのメモリ確保はどのように行うのですか?

それが分かれば、疑問は消えるのでしょう。

以下はコードの全体像です。

INDICATOR_DATA は描画されるデータ である。このバッファ(サイズ)はターミナルで監視されています(私の理解ではrates_totalによって)。

中間計算(INDICATOR_CALCULATIONS)用のバッファを追加します。それらのために、サイズを設定します。

PS 私は #include <TimeSeries.mqh> can "t なぜか開く、コンパイルされません。

アップマンデーは待ってください、何か変です。

 
Silent:

INDICATOR_DATA は描画されるデータ である。このバッファ(サイズ)を端末で監視しています(rates_totalによるものと理解しています)。

中間計算(INDICATOR_CALCULATIONS)用のバッファを追加します。それらのために、サイズを設定します。

追記 #include <TimeSeries.mqh>がなぜか開けず、コンパイルできません。

アップマンデーは待ってください、何か変です。

すでに変更しようとしましたが、まだ同じエラーです。せめて普通の配列に値を入れてみる、何かうまくいくかもしれない。
 
Al_key:
変更してみましたが、やはり同じエラーが発生しました。せめて普通の配列に値を入れてみる、何かうまくいくかもしれない。

ここでは、簡単なものを紹介します。INDICATOR_DATAでは、INDICATOR_CALCULATIONSから書き込みます。

#property indicator_separate_window
#property indicator_buffers 2
#property indicator_plots   1
//--- plot Label1
#property  indicator_label1  "Label1"
#property  indicator_type1   DRAW_LINE
#property  indicator_color1  clrOrangeRed
#property  indicator_style1  STYLE_SOLID
#property  indicator_width1  1
//--- input parameters
input string   s="EURUSD";
input ENUM_TIMEFRAMES      tf;          // D1
input int      countBars=100;          // count
//--- put parameters
int   copied,i;
//--- indicator buffers
double         Label1Buffer[];
//--- buffers
double         p_Symbol[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
   SetIndexBuffer(0,Label1Buffer,INDICATOR_DATA);
   SetIndexBuffer(1,p_Symbol,INDICATOR_CALCULATIONS);
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Custom indicator iteration function                              |
//+------------------------------------------------------------------+
int OnCalculate(const int rates_total,
                const int prev_calculated,
                const int begin,
                const double &price[])
  {
//---
   if(prev_calculated==0)
     {
      ArrayInitialize(Label1Buffer,EMPTY_VALUE);
      ArrayInitialize(p_Symbol,EMPTY_VALUE);
      ArraySetAsSeries(Label1Buffer,true);
      ArraySetAsSeries(p_Symbol,true);
      ArraySetAsSeries(price,true);
     };
   ArrayCopy(p_Symbol,price,0,0,countBars);
   if(_LastError!=0) {Print(_LastError); return(prev_calculated);};
   if(_LastError==0)
     {
      for(i=countBars;i>0;i--)
        {
         Label1Buffer[i]=p_Symbol[i];
         Print("limitBars i = "+IntegerToString(i));
        };
     };
//--- return value of prev_calculated for next call
   return(rates_total);
  }
 
Silent:

INDICATOR_DATA は描画されるデータ である。このバッファ(サイズ)を端末で監視しています(rates_totalによるものと理解しています)。

中間計算(INDICATOR_CALCULATIONS)用のバッファを追加します。それらのために、サイズを設定します。

PS 私は #include <TimeSeries.mqh> can "t なぜか開く、コンパイルされません。

アップマンデーは待ってください、何かがおかしいのです。

こちらもどうぞ : https://www.mql5.com/ru/code/1008

見つけたばかりで、だからまだコードを実感していない。 そして、まだ動かないだろう--ここの一般人が私を買い物に駆り立てている。

私は問題のコードがOnInit()からOnCalculate()に移動される場合、すべてが動作すると思います。 長い間、私は5つの特徴を知っていました - OnInitの任意のコードは正常に動作しません。 それはおそらく、SetIndexBuffer()を通じて 登録したバッファの本当の自動配布は、OnInit()から終了後にのみ終了すると保証されており、バックグラウンド(それは自動ですよね)で起こるはずだから です。

TimeSeries - Библиотека функций для работы с таймсериями
TimeSeries - Библиотека функций для работы с таймсериями
  • 投票: 12
  • 2012.08.24
  • Andrey Khatimlianskii
  • www.mql5.com
Библиотека функций для работы с таймсериями: iBars, iTime, iOpen, iHigh, iLow, iClose, iVolume, iHighest, iLowest, iBarshift. Для всех функций доступен краткий вариант вызова (с символом и периодом текущего графика).
 

クラウドからタスクを受信する際、8つのエージェントのうち3つしか同時に実行できないことに気づきました。
テストを並行して実行すると、他のエージェントも有効になってしまいますが。

これがあるべき姿なのか?