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

 
Vitaly Muzichenko:

这是否曾经起过作用,或者没有?

我怎样才能使它在输入参数中改变颜色时,这个颜色在"indicator_color1" ?现在,无论你如何改变它,它都是原来的样子。

Comment(Buffer1_Color[0]);

这个怎么样?

 
Сергей Таболин:

这个怎么样?

 
Vitaly Muzichenko:

这是否曾经起过作用,或者没有?

我怎样才能使它在输入参数中改变颜色时,这个颜色在"indicator_color1" ?现在,无论你怎么改,它都是原来的那个。

有些东西可以这样追溯。

//+------------------------------------------------------------------+
//|                                                         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"
#property indicator_chart_window
#property indicator_buffers 1
#property indicator_plots   1
//--- plot Label1
#property indicator_label1  "Label1"
#property indicator_type1   DRAW_LINE
#property indicator_color1  clrDarkGoldenrod
#property indicator_style1  STYLE_SOLID
#property indicator_width1  1
//--- indicator buffers
double         Label1Buffer[];
//+------------------------------------------------------------------+
//| Custom indicator initialization function                         |
//+------------------------------------------------------------------+
int OnInit()
  {
//--- indicator buffers mapping
   SetIndexBuffer(0,Label1Buffer,INDICATOR_DATA);

//---
   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[])
  {
//---
   Print(PlotIndexGetInteger(0,PLOT_LINE_COLOR,0));
//--- return value of prev_calculated for next call
   return(rates_total);
  }
//+------------------------------------------------------------------+
附加的文件:
Test.mq5  5 kb
 
Vladimir Karputov:

有些东西可以这样追溯。

很好,我们开始吧:PlotIndexGetInteger(0,PLOT_LINE_COLOR,0)

谢谢你!

 

如何在自定义指标 中只从OnCalculate()中获取分钟时间序列的数据,在任何时间框架上?我使用CopyRates(sym,PERIOD_M1,...),什么是最好的方法,你有什么建议?

 
Vladimir M.:

如何从任何时间段的分钟时间序列的OnCalculate()中获取自定义指标 的数据?我使用CopyRates(sym,PERIOD_M1,...),什么是最好的方法,你有什么建议?

如果你一次需要多条,你不会找到更好的东西。我认为通过CopyRates来接收一个酒吧的值会更好。

 
Alexey Viktorov:

如果你一次需要多条,你不会找到更好的东西。在我看来,通过CopyRates获取一个条形图的值更好。

另一方面,由于OnCalculate() 无用,我不能从指标中删除它。事实证明,你得到了两次相同的数据?
 
Vladimir M.:
OnCalculate()不能从指标中删除,因为它不需要。事实证明,你得到了两次相同的数据?

如果OnTick()存在,是否可以不使用它?

 
Vladimir M.:
另一方面,你不能从指标中删除OnCalculate(),因为它不需要。事实证明,你得到了两次相同的数据?

好吧,如果你不需要它,你可以使用第二个变体

int OnCalculate (const int rates_total,      // размер массива price[] 
                 const int prev_calculated,  // обработано баров на предыдущем вызове 
                 const int begin,            // откуда начинаются значимые данные 
                 const double& price[]       // массив для расчета 
   );
 
Igor Zakharov:

如果OnTick()存在,是否可以不使用它?

我怀疑这是否可能,但我不会再尝试了。而文件中说。

"......NewTick 事件只在专家顾问收到一个符号的新tick时产生,该符号与专家顾问所在的图表相连。在自定义指标 或脚本中定义OnTick()函数是没有用的,因为不会为它们生成NewTick事件..."。