There is initialisation in OnCalculate() at first run (prev_calculated == 0). Do you think moving it to OnInit() will change anything? Well, I'll try, of course, but this is something out of the realm of fantasy...
Cut. As I said, in OnDeinit() arrays are initialized, which are no longer used at next startup (changing input parameters). If this (initializing an array that isn't used as a buffer) helps - it would also be a MT bug. It would turn out that not only are the arrays not used, but they (unallocated) could still be initialized and it would affect the mapping...
Without code it's hard. Let us know what the service desk says afterwards.
Anatoli Kazharski: It's difficult without code. Let me know here later what the service desk says.
Here's the test code, if you're interested.
Initially, the indicator parameter is false.
We put the indicator on the chart. It plots a histogram.
We set the parameters as true.
It draws the histogram and arrows.
Make the parameter false. On the current TF arrows disappear (not always). If we switch to different TFs, arrows appear chaotically in some of them in spite of buffers clearing at deinitialization.
#property indicator_separate_window#property indicator_plots3#property indicator_buffers4//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+inputbool inpUseArrows=false;
//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+double bufGisto[];
double bufGistoColor[];
double bufArrowUp[];
double bufArrowDn[];
//---constdoubleEMPTY=EMPTY_VALUE;
//+------------------------------------------------------------------+//| Custom indicator initialization function |//+------------------------------------------------------------------+intOnInit()
{
//--- Размечаем массив цветовcolor colors[2];
colors[ 0 ]= clrLime;
colors[ 1 ] = clrRed;
//--- Устанавливаем параметры графических серий
SetPlotParametersColorHistogram(0,0,bufGisto,bufGistoColor,false,"test gisto",colors,EMPTY,2);
//--- Проверяем, нужно ли отображать объемыif(inpUseArrows) // Если отображать нужно
{
SetPlotParametersArrow(1,2,bufArrowUp,false,"test up",EMPTY,clrLime,233,10);
SetPlotParametersArrow(2,3,bufArrowDn,false,"test dn",EMPTY,clrRed,234,-10);
}
//---IndicatorSetInteger(INDICATOR_DIGITS,0);
//---return(INIT_SUCCEEDED);
}
//+------------------------------------------------------------------+//| |//+------------------------------------------------------------------+voidOnDeinit(constint reason)
{
if(inpUseArrows)
{
ArrayInitialize(bufArrowUp,EMPTY);
ArrayInitialize(bufArrowDn,EMPTY);
}
}
//+------------------------------------------------------------------+//| Custom indicator iteration function |//+------------------------------------------------------------------+intOnCalculate(constint rates_total,
constint prev_calculated,
constdatetime &time[],
constdouble &open[],
constdouble &high[],
constdouble &low[],
constdouble &close[],
constlong &tick_volume[],
constlong &volume[],
constint &spread[])
{
//---if(prev_calculated==0)
{
ArrayInitialize(bufGisto,EMPTY);
//---if(inpUseArrows)
{
ArrayInitialize(bufArrowUp,EMPTY);
ArrayInitialize(bufArrowDn,EMPTY);
}
//---for(int i=0; i<rates_total; i++)
{
bufGisto[i]=(open[i]-close[i])/_Point;
bufGistoColor[i]=(bufGisto[i]<0) ? 1 : 0;
//---if(inpUseArrows)
{
if(bufGisto[i]>20)
bufArrowDn[i]=bufGisto[i];
elseif(bufGisto[i]<-20)
bufArrowUp[i]=bufGisto[i];
}
}
}
elseif(rates_total>prev_calculated)
{
bufGisto[rates_total-1]=EMPTY;
//---if(inpUseArrows)
{
bufArrowUp[ rates_total-1 ] = EMPTY;
bufArrowDn[ rates_total-1 ] = EMPTY;
}
}
//--- return value of prev_calculated for next callreturn(rates_total);
}
//+------------------------------------------------------------------+//| Параметры графического построения: цветная гист-а от 0 линии |//+------------------------------------------------------------------+void SetPlotParametersColorHistogram(constint plotIndex,// Индекс графической серииconstint bufferNum,// Номер первого буфера серииdouble& value[], // Буфер значенийdouble& clr[], // Буфер цветовconstbool asSeries, // Флаг нумерации как в таймсерииconststring label, // Имя серииconstcolor& colors[], // Цвета линииconstdouble emptyValue = EMPTY_VALUE, // Пустые значения серииconstint width = 0, // Толщина линииconstENUM_LINE_STYLE style = STYLE_SOLID, // Стиль линииconstint drawBegin = 0, // Количество баров без отрисовкиconstint shift=0// Сдвиг построения в барах
)
{
//--- Привязываем буферыSetIndexBuffer(bufferNum,value,INDICATOR_DATA);
SetIndexBuffer(bufferNum+1,clr,INDICATOR_COLOR_INDEX);
//--- Устанавливаем порядок нумерации в массивах-буферахArraySetAsSeries(value,asSeries);
ArraySetAsSeries(clr,asSeries);
//--- Устанавливаем тип графического построенияPlotIndexSetInteger(plotIndex,PLOT_DRAW_TYPE,DRAW_COLOR_HISTOGRAM);
//--- Устанавливаем имя графической серииPlotIndexSetString(plotIndex,PLOT_LABEL,label);
//--- Устанавливаем пустые значения в буферахPlotIndexSetDouble(plotIndex,PLOT_EMPTY_VALUE,emptyValue);
//--- Устанавливаем количество цветов индикатораconstint size=ArraySize(colors);
PlotIndexSetInteger(plotIndex,PLOT_COLOR_INDEXES,size);
//--- Устанавливаем цвета индикатораfor(int i=0; i<size; i++)
PlotIndexSetInteger(plotIndex,PLOT_LINE_COLOR,i,colors[i]);
//--- Устанавливаем толщину линииPlotIndexSetInteger(plotIndex,PLOT_LINE_WIDTH,width);
//--- Устанавливаем стиль линииPlotIndexSetInteger(plotIndex,PLOT_LINE_STYLE,style);
//--- Устанавливаем количество баров без отрисовки и значений в DataWindowPlotIndexSetInteger(plotIndex,PLOT_DRAW_BEGIN,drawBegin);
//--- Устанавливаем сдвиг графического построения по оси времени в барахPlotIndexSetInteger(plotIndex,PLOT_SHIFT,shift);
}
//+------------------------------------------------------------------+//| Параметры графического построения: стрелки |//+------------------------------------------------------------------+void SetPlotParametersArrow(constint plotIndex,// Индекс графической серииconstint bufferNum,// Номер первого буфера серииdouble &value[],// Буфер значенийconstbool asSeries,// Флаг нумерации как в таймсерииconststring label,// Имя серииconstdouble emptyValue=EMPTY_VALUE,// Пустые значения серииconstcolor clr=clrRed,// Цвет стрелокconstint arrowCode= 159,// Код стрелокconstint arrowShift = 0,// Сдвиг стрелок по вертикалиconstint width=0,// Толщина стрелокconstint drawBegin=0,// Количество баров без отрисовкиconstint shift=0// Сдвиг построения в барах
)
{
//--- Привязываем буферыSetIndexBuffer(bufferNum,value,INDICATOR_DATA);
//--- Устанавливаем порядок нумерации в массивах-буферахArraySetAsSeries(value,asSeries);
//--- Устанавливаем тип графического построенияPlotIndexSetInteger(plotIndex,PLOT_DRAW_TYPE,DRAW_ARROW);
//--- Устанавливаем имя графической серииPlotIndexSetString(plotIndex,PLOT_LABEL,label);
//--- Устанавливаем пустые значения в буферахPlotIndexSetDouble(plotIndex,PLOT_EMPTY_VALUE,emptyValue);
//--- Устанавливаем цвет индикатораPlotIndexSetInteger(plotIndex,PLOT_LINE_COLOR,0,clr);
//--- Устанавливаем код стрелокPlotIndexSetInteger(plotIndex,PLOT_ARROW,arrowCode);
//--- Устанавливаем смещение стрелок по вертикалиPlotIndexSetInteger(plotIndex,PLOT_ARROW_SHIFT,arrowShift);
//--- Устанавливаем толщину стрелокPlotIndexSetInteger(plotIndex,PLOT_LINE_WIDTH,width);
//--- Устанавливаем количество баров без отрисовки и значений в DataWindowPlotIndexSetInteger(plotIndex,PLOT_DRAW_BEGIN,drawBegin);
//--- Устанавливаем сдвиг графического построения по оси времени в барахPlotIndexSetInteger(plotIndex,PLOT_SHIFT,shift);
}
//+------------------------------------------------------------------+
Regardless of whether you specify arrays for the arrows as buffers, they are still hardwired:
//---
Alternatively, if arrows do not need to be displayed, they can simply be excluded from display by DRAW_NONE.
Try this variant:
I thought about it, but there is a disadvantage here. Arrays will be automatically marked and expanded, eating up resource. The developers'd better let the bug be fixed.
And what about being hard-coded... If I don't bind buffers to graphical series - why do I see some unknown rubbish, which I can't get rid of.
Otherwise it turns out that dynamic indicators cannot be built normally.
The most ideal option is to clean buffers in deinit and that's it. But clearing doesn't help...
It would be nice to introduce a distinction on string type as it is used in other languages to a regular string and a "raw" string. I think they will come to this anyway, but at the initial stage it would eliminate many problems in the future.
For example Python uses r "string" to create a "raw" string
There is initialisation in OnCalculate() at first run (prev_calculated == 0). Do you think moving it to OnInit() will change anything? Well, I'll try, of course, but this is something out of the realm of fantasy...
Cut. As I said, in OnDeinit() arrays are initialized, which are no longer used at next startup (changing input parameters). If this (initializing an array that isn't used as a buffer) helps - it would also be a MT bug. It would turn out that not only are the arrays not used, but they (unallocated) could still be initialized and it would affect the mapping...
It's difficult without the code. Let me know what the service department says afterwards.
It's difficult without code. Let me know here later what the service desk says.
Here's the test code, if you're interested.
Initially, the indicator parameter is false.
We put the indicator on the chart. It plots a histogram.
We set the parameters as true.
It draws the histogram and arrows.
Make the parameter false. On the current TF arrows disappear (not always). If we switch to different TFs, arrows appear chaotically in some of them in spite of buffers clearing at deinitialization.
It doesn't go in any way. Service Desk #1832411x64, 1643.
Regardless of whether you specify arrays for the arrows as buffers, they are still hardwired:
//---
Alternatively, if arrows do not need to be displayed, they can simply be excluded from display by DRAW_NONE.
Try this way:
Regardless of whether you specify arrays for the arrows as buffers, they are still hardwired:
//---
Alternatively, if arrows do not need to be displayed, they can simply be excluded from display by DRAW_NONE.
Try this variant:
I thought about it, but there is a disadvantage here. Arrays will be automatically marked and expanded, eating up resource. The developers'd better let the bug be fixed.
And what about being hard-coded... If I don't bind buffers to graphical series - why do I see some unknown rubbish, which I can't get rid of.
Otherwise it turns out that dynamic indicators cannot be built normally.
The most ideal option is to clean buffers in deinit and that's it. But clearing doesn't help...
In ME, please show ALT+M in the list of functions/methods the type of return value.
It would be nice to introduce a distinction on string type as it is used in other languages to a regular string and a "raw" string. I think they will come to this anyway, but at the initial stage it would eliminate many problems in the future.
For example Python uses r "string" to create a "raw" stringWhat's the reason for not fully outputting the logs in the tester? Everything you can look at has been looked at and checked, can't beat it.
What is the reason for the logs not being fully displayed in the tester? All that can be looked at - looked at and checked, can't beat it.
A lot of entries. See log file.