This is my OnBarUpdate.I am getting the indicator output only for the last bar where as it should appear for all the bars on the chart.
Given below is my OnBarUpdate code:
protected override void OnBarUpdate()
{
this._price = (this.Open[0] + this.High[0] + this.Low[0] + this.Close[0]) / 4.0;
if (Bars.IsFirstBarOfSession)
{
this._VolumeSUM[0] = this.Volume[0];
this._VolumePriceSUM[0] = this.Volume[0] * this._price;
this._VolumePrice2SUM[0] = this.Volume[0] * this._price * this._price;
}
else
{
this._VolumeSUM[0] = this._VolumeSUM[1] + this.Volume[0];
this._VolumePriceSUM[0] = this._VolumePriceSUM[1] + this.Volume[0] * this._price;
this._VolumePrice2SUM[0] = this._VolumePrice2SUM[1] + this.Volume[0] * this._price * this._price;
}
this.Values[0][0] = this._VolumePriceSUM[0] / this._VolumeSUM[0];
this._deviation = Math.Sqrt(Math.Max(0, this._VolumePrice2SUM[0] / this._VolumeSUM[0] - this.Values[0][0] * this.Values[0][0]));
if (this._std1 > 0)
{
this.Values[1][0] = this.Values[0][0] + this._std1 * this._deviation;
this.Values[2][0] = this.Values[0][0] - this._std1 * this._deviation;
}
else
{
this.Values[1].Reset();
this.Values[2].Reset();
}
if (this._std2 > 0)
{
this.Values[3][0] = this.Values[0][0] + this._std2 * this._deviation;
this.Values[4][0] = this.Values[0][0] - this._std2 * this._deviation;
}
else
{
this.Values[3].Reset();
this.Values[4].Reset();
}
}
I am not understanding how to loop through and display output for all the visible bars,can anyone post examples to loop through all the bars
Comment