初学者的问题 MQL5 MT5 MetaTrader 5 - 页 1192

 
Artem Mordvinkin:


它以通俗的英语写道,符号自动连接到测试中

当你访问它们时。
 
Artem Mordvinkin:


是的,俄语中写道,在测试过程中,符号会自动连接。

创建一个指标,你必须首先在Market Watch中连接一个符号(在你的例子中是在测试器的Market Watch中)。

 
Artyom Trishkin:
要求从每个所需的符号中获取任何数据。

他们由SymbolSelect()丢失 - 未被选中

亲爱的先生们 在向我推荐出版物之前(为此我感谢你们),请检查--你们的多币种是否在测试器中工作。

 
Artem Mordvinkin:

他们由SymbolSelect()丢失 - 未被选中

亲爱的先生们 在向我推荐出版物之前(为此我感谢你们),请检查--你们的多币种是否在测试器中工作。

他们的工作。在最新的构建中。一点问题都没有。
 
Artyom Trishkin:
它是有效的。在最新的构建中。一点问题都没有。

你是如何连接它们的(符号)--你能告诉我哪个功能吗?

 
Artem Mordvinkin:

你是如何连接它们的(符号)--你能告诉我哪个功能吗?

SymbolSelect(character name,true)。

 
Vladimir Karputov:

SymbolSelect(character name,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不存在


该电缆没有出现错误,因为它在测试器中被选中。

符号名称是正确的。


在我看来,它需要在终端设置本身做一些事情。如果在上次构建之前一切都在工作,那就与代码无关。测试员看不到这些符号。

 
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:

它是什么?代码在哪里?你如何得到它?特别是你选择了完全不同的角色。

明白了,我们这样走吧。

给定(人物名称)


代码(片段)

//----------------------------название инструмента
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);
  }
//+------------------------------------------------------------------+

结果是正确的。首先选择符号,然后用它创建指标。


附加的文件: