Wishes for MT5 - page 62

 
Yedelkin:

You just have to specify a non-existent window number.

I.e. specify INT_MAX, for example. Or a negative value (I haven't tried it myself, but as an idea you can try it).


int win_ind=1;

int OnInit()
  {
//---
   chart_id=ChartID();
//--- set balans ind

   MqlParam params[1];
   params[0].type         =TYPE_STRING;
   params[0].string_value =name_ind;
   handle=IndicatorCreate(ChartSymbol(chart_id),ChartPeriod(chart_id),IND_CUSTOM,win_ind,params); // вот тут ещё 
                                                                              // прокатит несуществующее окно
   ChartIndicatorAdd(chart_id,win_ind,handle); // а вот тут уже нужно точно знать его номер
   win_ind=ChartWindowFind(chart_id,name_ind); // а получить его можно только тут   
//---
   return(0);
  }

That is why you have to specify win_ind explicitly, otherwise it will not work.

 

Urain:

Yedelkin:

You just have to specify a non-existent window number.

I.e. specify INT_MAX, for example. Or a negative value (I haven't tried it myself, but as an idea, you can try it).

That's because I haven't tried it, that's why you advise so

OK, if you have checked the idea of specifying negative values and it does not prove to be true, let's stop at the first hint:

"You just have to specify a non-existent window number, e.g. specify INT_MAX". That is, in the above example specify

ChartIndicatorAdd(chart_id,INT_MAX,handle); // указываем заранее несуществующий номер подокна

Or, in your case, when specifying a non-existing window number, theChartIndicatorAdd function refuses to work and create a new subwindow?

By the way, it's not quite clear why you have the same variable in your code

int win_ind=1;
is first used as the fourth parameter of theIndicatorCreate function (where the fourth parameter == number of parameters passed in the parameters_array[] array) and then used as the second parameter of theChartIndicatorAdd function (where the second parameter == chart subwindow number).
 
Документация по MQL5: Операции с графиками / ChartIndicatorsTotal
Документация по MQL5: Операции с графиками / ChartIndicatorsTotal
  • www.mql5.com
Операции с графиками / ChartIndicatorsTotal - Документация по MQL5
 

Is this what you mean?

CHART_WINDOWS_TOTAL

Total number of chart windows, including indicator subwindows

int r/o

 
Taki yes :) By doing a double loop you can go through all the chart indices without too much trouble.
 
Yedelkin:

By the way, it's not quite clear why you have the same variable in your code

first it is used as the fourth parameter ofIndicatorCreate function (where the fourth parameter == number of parameters passed in array parameters_array[]) and then it is used as the second parameter ofChartIndicatorAdd function (where the second parameter == chart subwindow number).

Semyon Semyonych, that's right. I was careless when writing win_ind explicitly everywhere as 1 and then, when replacing it with a variable, I changed all 1's to win_ind. That's what gave you the electric shock :o)

The correct code would be this

int win_ind=-1;

int OnInit()
  {
//---
   chart_id=ChartID();
//--- set balans ind

   MqlParam params[1];
   params[0].type         =TYPE_STRING;
   params[0].string_value =name_ind;
   handle=IndicatorCreate(ChartSymbol(chart_id),ChartPeriod(chart_id),IND_CUSTOM,1,params);// 1- количество параметров 
                                                                              
   ChartIndicatorAdd(chart_id,win_ind,handle); // тут поскольку win_ind=-1 создаём новое окно
   win_ind=ChartWindowFind(chart_id,name_ind); // а тут получаем значение win_ind 
//---
   return(0);
  }

Now yes, everything works automatically. Thanks for the code parsing, one head is good but two is better :o)

 
TheXpert:
Taki yes :) By doing a double loop you can go through all the chart indices without too much trouble.
It's OK! But for my purposes I managed to avoid the loop.
 
There were suggestions about extending the list of pending orders about six months ago. For example, to introduce OCO-type orders, etc. What is the current state of progress of those ideas? Can we hope for the appearance (at least in a year) of new types of pending orders?
Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров
Документация по MQL5: Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров
  • www.mql5.com
Стандартные константы, перечисления и структуры / Торговые константы / Свойства ордеров - Документация по MQL5
 
Unfortunately, no. The warrant system will not change.
 
Renat:
Unfortunately, no. The warrant system is not going to change.
OK, so we'll go with what we have.