Problem with custom indicator redraw

 
Hello,

I have a custom indicator that has two buffers, one is histograms, the other is a line. The line is a 6 period average of the histogram values.

When I drop the indicator on the chart, everything is ok.

When I go to the property sheet and click ok, OR, when I change periodicities, the history of the line disappears and the line only is drawn from bar 1 to bar 0. The histograms are still visible. Here is how the line is calculated:

// SignalValue and SignalAvg are buffers
SignalValue[iCurBar]=myValue;
SignalAvg[iCurBar]=iMAOnArray(SignalValue,0,periodsToAverage,0,MODE_SMA,iCurBar);

The code is in a for loop in the start() code that iterates the bars from highest down to zero.

Any tips or help is greatly appreciated. I'm stuck on this one.

Thanks,

Christian
 
// SignalValue and SignalAvg are buffers
SignalValue[iCurBar]=myValue;
SignalAvg[iCurBar]=iMAOnArray(SignalValue,0,periodsToAverage,0,MODE_SMA,iCurBar);
This is a known issue. Calculate buffers in separate loops. iMaOnArray needs fully prepared data.
 
Thank you very much, that worked great.