初心者の方からの質問 MQL5 MT5 MetaTrader 5 - ページ 1192

 
Artem Mordvinkin:


記号が自動的にテストにつながることがわかりやすく書かれています

アクセスしたとき。
 
Artem Mordvinkin:


はい、ロシア語では、テスト中にシンボルが自動的に接続されるように書かれています

インジケータを作成 するには、まずMarket Watchでシンボルを接続する必要があります(あなたの場合はテスターのMarket Watchで)。

 
Artyom Trishkin:
各シンボルから任意のデータを要求する。

SymbolSelect()で選択されたものが欠落している - 選択されていない

出版物(私はあなたに感謝するために)に私を参照する前に、親愛なる卿 - あなたのマルチ通貨はテスターで動作するかどうか、そして、彼らが行う場合、それは理にかなっています。

 
Artem Mordvinkin:

SymbolSelect()で選択されたものが欠落している - 選択されていない

出版物(私はあなたに感謝するために)に私を参照する前に、親愛なる卿 - あなたのマルチ通貨はテスターで動作するかどうか、そして、彼らが行う場合、それは理にかなっています。

働いているのです。最新ビルドで。全く問題ありません。
 
Artyom Trishkin:
効くんです。最新ビルドで。全く問題ありません。

どのように接続したのか(記号)、どの機能かわかるか?

 
Artem Mordvinkin:

どのように接続したのか(記号)、どの機能かわかるか?

SymbolSelect(文字名,true);

 
Vladimir Karputov:

SymbolSelect(文字名,true)。

私もそうしています。

SymbolSelect(EURUSD_inst, true);
  SymbolSelect(GBPUSD_inst, true);
  SymbolSelect(USDJPY_inst, true);
  SymbolSelect(AUDUSD_inst, true);


こんな風に受け取ります

2020.03.09 19:19:45.766 シンボルEURUSDrfdは存在しません。

2020.03.09 19:19:45.766 シンボル USDJPYrfd は存在しません。

2020.03.09 19:19:45.766 シンボル AUDUSDrfd は存在しません。


テスターでケーブルが選択されているため、エラーにならない。

シンボル名は正しいです。


UPDは、端末の設定自体で何かする必要があるように思います。前回のビルドの前にすべてが動作していたのであれば、コードとは関係ありません。テスターはシンボルを見ることができない。

 
Artem Mordvinkin:


2020.03.09 19:19:45.766 シンボルEURUSDrfdは存在しません。

2020.03.09 19:19:45.766 シンボル USDJPYrfd は存在しません。

2020.03.09 19:19:45.766 シンボル AUDUSDrfd は存在しません。


ケーブルはテスターで選択されているため、エラーは発生しない

何ですか?コードはどこにあるのですか?どうやって手に入れるの?特に、まったく違うキャラクターを選んでいますね。

 
Vladimir Karputov:

何ですか?コードはどこにあるのですか?どうやって手に入れるの?特に、全く違うキャラクターを選んでいるわけですから。

了解、こんな感じで行きましょう。

Given(登場人物の名前)


コード(断片)

//----------------------------название инструмента
string EURUSD_inst = "EURUSDrfd";
string GBPUSD_inst = "GBPUSDrfd";
string AUDUSD_inst = "AUDUSDrfd";
string USDJPY_inst = "USDJPYrfd";


void OnTick()
  {
  SymbolSelect(EURUSD_inst, true);
  SymbolSelect(GBPUSD_inst, true);
  SymbolSelect(USDJPY_inst, true);
  SymbolSelect(AUDUSD_inst, true);
}

例としてテスターのケーブルを選択してみましょう。


実行し

2020.03.09 19:19:45.766 シンボルEURUSDrfdは存在しません。

2020.03.09 19:19:45.766 シンボル USDJPYrfd は存在しません。

2020.03.09 19:19:45.766 シンボル AUDUSDrfd は存在しません。

ケーブルにエラーがない - テスターのデフォルトで選択されている

また、念のため申し上げておきますが、この問題はテスターにしかありません。そして、このフクロウは数年前のもので、エラーは2日前のもので、これは私の多通貨のフクロウ全てに言えることだと言うことです。
 

USDJPY'シンボルでiMAインディケータを作成し、'EURUSD'でテスターを動作させた例です。

//+------------------------------------------------------------------+
//|                                        iMA Values on a Chart.mq5 |
//|                              Copyright © 2019, Vladimir Karputov |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2019, Vladimir Karputov"
#property version   "1.001"
//--- input parameters
input  string              Inp_MA_symbol        = "USDJPY";    // MA: symbol name
input ENUM_TIMEFRAMES      Inp_MA_period        = PERIOD_D1;   // MA: timeframe
input int                  Inp_MA_ma_period     = 12;          // MA: averaging period
input int                  Inp_MA_ma_shift      = 5;           // MA: horizontal shift
input ENUM_MA_METHOD       Inp_MA_ma_method     = MODE_SMA;    // MA: smoothing type
input ENUM_APPLIED_PRICE   Inp_MA_applied_price = PRICE_CLOSE; // MA: type of price
//---
int    handle_iMA;                           // variable for storing the handle of the iMA indicator
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
   if(!SymbolSelect(Inp_MA_symbol,true))
     {
      PrintFormat("Failed select symbol %s",
                  Inp_MA_symbol);
      return(INIT_FAILED);
     }
//--- create handle of the indicator iMA
   handle_iMA=iMA(Inp_MA_symbol,Inp_MA_period,Inp_MA_ma_period,Inp_MA_ma_shift,
                  Inp_MA_ma_method,Inp_MA_applied_price);
//--- if the handle is not created
   if(handle_iMA==INVALID_HANDLE)
     {
      //--- tell about the failure and output the error code
      PrintFormat("Failed to create handle of the iMA indicator for the symbol %s/%s, error code %d",
                  Inp_MA_symbol,
                  EnumToString(Inp_MA_period),
                  GetLastError());
      //--- the indicator is stopped early
      return(INIT_FAILED);
     }
//---
   return(INIT_SUCCEEDED);
  }
//+------------------------------------------------------------------+
//| Expert deinitialization function                                 |
//+------------------------------------------------------------------+
void OnDeinit(const int reason)
  {
//---

  }
//+------------------------------------------------------------------+
//| Expert tick function                                             |
//+------------------------------------------------------------------+
void OnTick()
  {
//---
   double array_ma[];
   ArraySetAsSeries(array_ma,true);
   int start_pos=0,count=3;
   if(!iGetArray(handle_iMA,0,start_pos,count,array_ma))
      return;

   string text="";
   for(int i=0; i<count; i++)
      text=text+IntegerToString(i)+": "+DoubleToString(array_ma[i],Digits()+1)+"\n";
//---
   Comment(text);
  }
//+------------------------------------------------------------------+
//| Get value of buffers                                             |
//+------------------------------------------------------------------+
bool iGetArray(const int handle,const int buffer,const int start_pos,
               const int count,double &arr_buffer[])
  {
   bool result=true;
   if(!ArrayIsDynamic(arr_buffer))
     {
      //if(InpPrintLog)
      PrintFormat("ERROR! EA: %s, FUNCTION: %s, this a no dynamic array!",__FILE__,__FUNCTION__);
      return(false);
     }
   ArrayFree(arr_buffer);
//--- reset error code
   ResetLastError();
//--- fill a part of the iBands array with values from the indicator buffer
   int copied=CopyBuffer(handle,buffer,start_pos,count,arr_buffer);
   if(copied!=count)
     {
      //--- if the copying fails, tell the error code
      //if(InpPrintLog)
      PrintFormat("ERROR! EA: %s, FUNCTION: %s, amount to copy: %d, copied: %d, error code %d",
                  __FILE__,__FUNCTION__,count,copied,GetLastError());
      //--- quit with zero result - it means that the indicator is considered as not calculated
      return(false);
     }
   return(result);
  }
//+------------------------------------------------------------------+

結果は正解です。まずシンボルを選択し、それを使ってインジケータを作成します。


ファイル:
理由: