Indicator 'MyIndicator': Error on calling 'OnRender' method on bar -1: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.
private Stroke stroke;
----
else if (State == State.Configure)
{
stroke = new Stroke(Brushes.Black, 2f);
}
protected override void OnBarUpdate()
{
if (State == State.Historical)
return;
}
protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
{
if (Bars == null)
return;
RectangleF rect = new RectangleF();
try
{
rect.X = chartControl.GetXByBarIndex(ChartBars, 0);
rect.Y = chartScale.GetYByValue(Close[0]);
rect.Width = 100;
rect.Height = 100;
RenderTarget.DrawRectangle(rect, stroke.BrushDX);
}
catch (Exception e)
{
Print (e.Message);
}
}

Comment