In the following code, there are 2 Dataseries : Barnum, which is automatically added by the Add(new Plot...) method, and the dsOpen dataseries which is added manually by code.
Both dataseries are set as value(bar)=bar number, so when plotting they should show a straight line.
This is OK for the Barnum bar series (red), but the manual bar series repeats the last values.
protected DataSeries dsOpen;
protected override void Initialize()
{
Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Barnum"));
CalculateOnBarClose = true;
Overlay = false;
if (Instrument != null)
{
dsOpen = new DataSeries(this);
}
}
protected override void OnBarUpdate()
{
dsOpen.Set(CurrentBar);
Barnum.Set(CurrentBar);
}
public override void Plot(Graphics graphics, Rectangle bounds, double min, double max)
{
int lastBar = Math.Min(ChartControl.LastBarPainted, Bars.Count - 1);
int barsPainted = ChartControl.BarsPainted;
int firstBar = Math.Max(0, (lastBar - barsPainted) + 1);
int x;
for (int idx = firstBar; idx <= lastBar; idx++)
{
x=ChartControl.GetXByBarIdx(Bars,idx);
graphics.DrawArc(new Pen(Color.Black,1),x,ChartControl.GetYByValue(this,dsOpen.Get(idx)),1,1,0,360);
graphics.DrawArc(new Pen(Color.Red,1),x,ChartControl.GetYByValue(this,Barnum.Get(idx)),1,1,0,360);
}
}

Comment