Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1011

 
Vitaly Muzichenko:

Has this ever worked, or not?

How can I make it so that when a colour is changed in the input parameters, this colour is in"indicator_color1" ? Right now, no matter how you change it, it's the original

Comment(Buffer1_Color[0]);

How about this?

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

How about this?

 
Vitaly Muzichenko:

Has this ever worked, or not?

How can I make it so that when a colour is changed in the input parameters, this colour is in"indicator_color1" ? Right now, no matter how you change it, it's the original one.

Something can be traced like this:

//+------------------------------------------------------------------+
//|                                                         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);
  }
//+------------------------------------------------------------------+
Files:
Test.mq5  5 kb
 
Vladimir Karputov:

Something can be traced like this:

Great, here we go:PlotIndexGetInteger(0,PLOT_LINE_COLOR,0)

Thank you!

 

How in custom indicator to get data from OnCalculate() only minute time series, on any timeframe? I'm using CopyRates(sym,PERIOD_M1,...), what's the best way, what do you advise?

 
Vladimir M.:

How to get data in a custom indicator from OnCalculate() of minute time series only, for any timeframe? I use CopyRates(sym,PERIOD_M1,...), whats the best way, whats your advice?

If you need multiple bars at once, you won't find anything better. And I think it's better to receive values of one bar by means of CopyRates

 
Alexey Viktorov:

If you need multiple bars at once, you won't find anything better. And in my opinion it's better to get the values of a single bar via CopyRates

On the other hand, I cannot remove OnCalculate() from the indicator due to its uselessness. It turns out that you get the same data twice?
 
Vladimir M.:
OnCalculate() cannot be removed from the indicator as it is not needed. It turns out that you get the same data twice?

Is it possible to do without it if OnTick() is present?

 
Vladimir M.:
On the other hand, you cannot remove OnCalculate() from the indicator because it is not needed. It turns out that you get the same data twice?

Well, if you don't need it, you can use the second variant

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

Is it possible to do without it if OnTick() is present?

I doubt it's possible, but I won't try it anymore. And the documentation says:

"...The NewTick event is generated only for Expert Advisors when a new tick is received for a symbol, to the chart of which the Expert Advisor is attached. It's useless to define the OnTick() function in a custom indicator or script, as the NewTick event is not generated for them ...".

Reason: