It's easy to do in OnBarUpdate()
protected override void OnBarUpdate()
{
if(CurrentBar < 500) return;
double y = .2;
int x = 10;
Draw.Text(this, "50", true, "50", 50, y, x, Brushes.White, displayFont, TextAlignment.Center,
Brushes.Transparent, Brushes.Transparent, 0);
Draw.Text(this, "100", true, "100", 100, y, x, Brushes.White, displayFont, TextAlignment.Center,
Brushes.Transparent, Brushes.Transparent, 0);
Draw.Text(this, "150", true, "150", 150, y, x, Brushes.White, displayFont, TextAlignment.Center,
Brushes.Transparent, Brushes.Transparent, 0);
Draw.Text(this, "200", true, "200",200, y, x, Brushes.White, displayFont, TextAlignment.Center,
Brushes.Transparent, Brushes.Transparent, 0);
Draw.Text(this, "250", true, "250", 250, y, x, Brushes.White, displayFont, TextAlignment.Center,
Brushes.Transparent, Brushes.Transparent, 0);
Draw.Text(this, "300", true, "300", 300, y, x, Brushes.White, displayFont, TextAlignment.Center,
Brushes.Transparent, Brushes.Transparent, 0);
Draw.Text(this, "350", true, "350", 350, y, x, Brushes.White, displayFont, TextAlignment.Center,
Brushes.Transparent, Brushes.Transparent, 0);
}
But I would like to scroll back and have the index still there based on the bar at the right edge of the screen. So I moved to OnRender()
I thought this would do it
protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
{
// if(ChartBars.FromIndex < 1000) return; // I don't need the indexing to start early, thought this would help but it didn't
int totalBars = ChartBars.Count; // the total number of bars on the chart
int rightBar = ChartBars.ToIndex; // the right bar visible on the chart
int i200 = 200 + totalBars - rightBar; // this is bar 200 from the right edge
Draw.TextFixed(this, "scale", rightBar + " " + totalBars + " " + i200,
TextPosition.TopRight, Brushes.White,
displayFont, Brushes.Transparent, Brushes.Transparent, 0);
double y = .2;
int x = 10;
Draw.Text(this, "200", true, "200", i200,
y, x, Brushes.White, displayFont,
TextAlignment.Center, Brushes.Transparent, Brushes.Transparent, 0);
}
I am able to correctly get the bar number for bar 200 on the chart (i200)
But when I try to use i200 in Draw.Text, I get the error
I know what to do in OnBarUpdate()... Put an if statement with a return until I have enough bars on the chart to do the calculation.
But I am able to calculate and display i200 in a Draw.TextFixed() box in the lower right corner. So its processing correctly at that point.
But when I use Draw.Text() it errors out.
Help please

Comment