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;
intOnInit()
{
//---
chart_id=ChartID();
//--- set balans indMqlParam 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.
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).
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;
intOnInit()
{
//---
chart_id=ChartID();
//--- set balans indMqlParam 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)
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?
Allow the use of cookies to log in to the MQL5.com website.
Please enable the necessary setting in your browser, otherwise you will not be able to log in.
You are signed in. Two-factor authentication has been disabled. Set it up again and scan a new QR code, or continue with two-factor authentication disabled.
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 is why you have to specify win_ind explicitly, otherwise it will not work.
Urain:
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
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
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).Read carefully.
https://www.mql5.com/ru/docs/chart_operations/chartindicatorstotal
Read carefully.
https://www.mql5.com/ru/docs/chart_operations/chartindicatorstotal
Is this what you mean?
CHART_WINDOWS_TOTAL
Total number of chart windows, including indicator subwindows
int r/o
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
Now yes, everything works automatically. Thanks for the code parsing, one head is good but two is better :o)
Taki yes :) By doing a double loop you can go through all the chart indices without too much trouble.
Unfortunately, no. The warrant system is not going to change.