Questions from Beginners MQL5 MT5 MetaTrader 5 - page 1343

 

Added to the code, does not print second and subsequent copies of the indicators

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[])
{
  OnInit();
   for(int i = prev_calculated == 0 ? 0 : prev_calculated - 1; i < rates_total; i++)
   {
      Label1Buffer[i] = close[i];
   }
   return(rates_total);
}

---

What's done:

Installed 3 copies of the indicator, compiled the file and got the print from the first copy

2021.09.12 18:30:40.975 Create_button (BTCUSD,M30)      INIT SUCCEEDED: 1
 
Vitaly Muzichenko #:

But if you change the input parameters - then it works.

have seen such messages on the forum, as far as I understood, the terminal does not run two copies of the indicator with the same parameters on the same chart

 
Igor Makanu #:

I've seen such messages on the forum, as far as I understood, the terminal does not run two copies of the indicator with the same parameters on the same chart

How can I make it run without changing the input parameters?

You need to install several copies, it's such a task, unfortunately

 
Vitaly Muzichenko #:

How can I make it run without changing the input parameters, maybe add something from define?

Need to set multiple copies, this is such a task, unfortunately.

Enter a fake parameter. And assign it 1, 2, 3 ...

 
Vitaly Muzichenko #:

How can I make it run without changing the input parameters, maybe add something from define?

Need to set multiple copies, this is such a challenge, unfortunately

have seen and tested how to make two subwindows by editing a template - one subwindow on top of the chart, the second in the basement

try saving a template with your indicator, and if it works this way with templates too - add a copy of the indicator to the text of the template

 
Igor Makanu #:

have seen and tested how to make two subwindows using template editing - one subwindow on top of the chart, the second in the basement

try saving a template with your indicator and if it works this trick with templates too - add a copy of the indicator to the text of the template

The issue is that they need to be thrown in different amounts randomly, so it won't work in a fixed way.

 
Igor Makanu #:

have seen and tested how to make two subwindows using template editing - one subwindow on top of the chart, the second in the basement

try to save a template with your indicator, and if it works the same trick with templates - add a copy of the indicator in the template text

I have downloaded 3 copies, OnInit worked once.

Changed the input value - the second indicator triggered

I changed the colour in the third - it worked as well


But how do I automate it?

 

then I don't know, I only see@Vladimir Karputov' s solution as acceptable

make a long input parameter and call randomly, and randomly generate a large one, i.e. long

 
Igor Makanu #:

then I don't know, I only see@Vladimir Karputov' s solution as acceptable

make a long input parameter and call randomly, and randomly generate a large one, i.e. long

I imagined it like this, but how to implement it?

Please show me the code!

 
Vitaly Muzichenko #:

That's roughly what I imagined, but how to implement it?

Please show me the code!

no way

If you call it programmatically, you can generate a parameter randomly

And you need to run it manually, you still need to change the input-parameter.


try to see what's in predefined macrosubstitutions, there was __COUNT___ and now there is something with random, I haven't checked how __COUNT___ works - it turns out static, it has little effect, maybe you can use random for your task