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

 

我无法从EA中获得高时间段的指标数据。

2019.07.22 07:23:02.556 Core 1  2017.10.05 07:00:00   Не удалось скопировать значения индикатора. Error =4806,  copied =-1

而在优化过程中,它是有效的。当我开始在可视化软件中运行它时,我得到了这个错误。

该指标有什么问题?

附加的文件:
ind.mq5  11 kb
 
EgorKim:

我无法从EA中获得高时间段的指标数据。

而在优化过程中,它是有效的。当我开始在可视化软件中运行它时,我得到了这个错误。

该指标有什么问题?

EA的代码在哪里?

可能的原因 - 在指标所在的路径(通过iCustom在顾问中 写入指标 的路径)。另外,指标mq5和ex5文件应该在同一个文件夹中。

 
EgorKim:

我无法从EA中获得高时间段的指标数据。

而在优化过程中,它是有效的。当我开始在可视化软件中运行它时,我得到了这个错误。

该指标有什么问题?

所以,你的指标位于[date folder]\MQL5\Indicators\ind.mq5,那里也有编译的文件。

一个访问指标缓冲区"0"-"Means "的专家顾问的例子。

//+------------------------------------------------------------------+
//|                                                         Test.mq5 |
//|                              Copyright © 2019, Vladimir Karputov |
//|                                           http://wmua.ru/slesar/ |
//+------------------------------------------------------------------+
#property copyright "Copyright © 2019, Vladimir Karputov"
#property link      "http://wmua.ru/slesar/"
#property version   "1.00"
//--- input parameters
input int      Input1=9;
//---
int    handle_iCustom;              // variable for storing the handle of the iCustom indicator /*
//+------------------------------------------------------------------+
//| Expert initialization function                                   |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- create handle of the indicator iCustom
   handle_iCustom=iCustom(Symbol(),Period(),"ind");
//--- if the handle is not created 
   if(handle_iCustom==INVALID_HANDLE)
     {
      //--- tell about the failure and output the error code 
      PrintFormat("Failed to create handle of the iCustom indicator for the symbol %s/%s, error code %d",
                  Symbol(),
                  EnumToString(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 means[];
   ArraySetAsSeries(means,true);
   int start_pos=0,count=3;
   if(!iGetArray(handle_iCustom,0,start_pos,count,means))
      return;

   string text="Means:"+"\n";
   for(int i=count-1;i>=0;i--)
     {
      text=text+"#"+IntegerToString(i)+": "+DoubleToString(means[i],Digits())+"\n";
     }
   Comment(text);
  }
//+------------------------------------------------------------------+
//| Get value of buffers                                             |
//+------------------------------------------------------------------+
double iGetArray(const int handle,const int buffer,const int start_pos,const int count,double &arr_buffer[])
  {
   bool result=true;
   if(!ArrayIsDynamic(arr_buffer))
     {
      Print("This a no dynamic array!");
      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 
      PrintFormat("Failed to copy data from the indicator, error code %d",GetLastError());
      //--- quit with zero result - it means that the indicator is considered as not calculated 
      return(false);
     }
   return(result);
  }
//+------------------------------------------------------------------+

以及测试器中的结果。


和在线。


附加的文件:
Test.mq5  7 kb
 
Vladimir Karputov:

所以,你的指标位于[date folder]\MQL5\Indicators\ind.mq5,那里也有编译的文件。

一个访问指标缓冲区"0"-"Means "的专家顾问的例子。

以及测试器中的结果。


而在网上。


我在当前的时间框架内没有错误。

如果我收到更高的时间框架的数据,问题就会出现。

显然,问题出在指标上,而不是在我的EA上)

而且在优化模式下也没有错误。当你启用单次通过和可视化时 - 有一个错误。错...

以下是我所理解的同一主题的题目

https://www.mql5.com/ru/forum/190003

Не получается брать данные индикатора со старшего ТФ
Не получается брать данные индикатора со старшего ТФ
  • 2017.04.14
  • www.mql5.com
Уже четвёртый день в индикаторе пытаюсь получить данные стандартного индикатора АО со старшего таймфрейма, и всё никак...
 
EgorKim:

我在当前的时间框架内没有错误。

如果我从更高的时间框架获取数据,问题就会出现。

问题显然出在指标上,而不是在我的EA上)

而且在优化模式下也没有错误。当你启用单次通过和可视化时 - 有一个错误。错...

以下是我所理解的同一主题的题目

https://www.mql5.com/ru/forum/190003

你没有参考高级的时间框架--其数据没有保持更新。
Проблема перевода с МТ4 на МТ5. Или, точнее, невозможность без'ошибочного исполнения некоторых алгоритмов в МТ5.
Проблема перевода с МТ4 на МТ5. Или, точнее, невозможность без'ошибочного исполнения некоторых алгоритмов в МТ5.
  • 2019.07.21
  • www.mql5.com
Сначала цитата из справочника языка MQL5. Рубрика Организация доступа к данным...
 

像这样把指标放在H1图表上,使用默认参数。

有一个错误

Artyom Trishkin

我请求帮助,在指标中修正什么?

附加的文件:
ind2.mq5  22 kb
 
EgorKim:

我在当前的时间框架内没有错误。

如果我从更高的时间框架获取数据,问题就会出现。

问题显然出在指标上,而不是在我的EA上)

而且在优化模式下也没有错误。当你启用单次通过和可视化时 - 有一个错误。错...

以下是我所理解的同一主题的题目

https://www.mql5.com/ru/forum/190003

这里有一个对COUNTER的修改--你可以 在参数中设置指标的时间框架。在测试器中和网上都能工作。

//--- create handle of the indicator iCustom
   handle_iCustom=iCustom(Symbol(),Inp_period,"ind",
                          bars_IN,
                          SP,
                          N_Shift1,
                          Forecast,
                          kstd,
                          Oscilator,
                          N_Buff,
                          Ka,
                          La,
                          Za,
                          Oe,
                          Me,
                          DIGf);
附加的文件:
Test.mq5  10 kb
 
Vladimir Karputov:

这里有一个对COUNTER的修改--你可以 在参数中设置指标的时间框架。它在测试器和网上都能工作。

那么我们如何解释专家顾问优化 过程中的交易呢?而在可视化的过程中,没有任何一个交易?

 
EgorKim:

那么如何解释在优化 过程中,专家顾问 的交易。而在可视化期间,没有交易?

开仓的条件是什么(指标缓冲数和条数)?

 
Vladimir Karputov:

开仓的条件是什么(指标缓冲数和条数)?

像这样。

而一些优化器的通行证在可视化器中是重合的。

而有些通行证根本就没有一个交易。

double price1=0.0;
price1=iCustomGet(handle_ind,1,0)
double price2=0.0;
price2=iCustomGet(handle_ind,2,0)
double open=0.0;   
double open          = iOpen(Symbol(),Period(),0);

   if(price1!=0.0 && price2!=0.0 && open!=0.0)
     {
      if(open<price1)
        {
         buy
        }
      if(open>price2)
        {
         sell
        }
      }
//+------------------------------------------------------------------+
//| Get value of buffers for the iCustom                             |
//|  the buffer numbers are the following:                           |
//+------------------------------------------------------------------+
double iCustomGet(int handle,const int buffer,const int index)
  {
   double Custom[1];
//--- reset error code 
   ResetLastError();
//--- fill a part of the iCustom array with values from the indicator buffer that has 0 index 
   if(CopyBuffer(handle,buffer,index,1,Custom)<0)
     {
      //--- if the copying fails, tell the error code 
      PrintFormat("Failed to copy data from the iCustom indicator, error code %d",GetLastError());
      //--- quit with zero result - it means that the indicator is considered as not calculated 
      return(0.0);
     }
   return(Custom[0]);
  }
//+------------------------------------------------------------------+

我认为问题出在指标上。

正如Artem所正确指出的,问题出在实际数据上。

它只是不愿意告诉我如何做)