I'd start processing each bar from the latest backward, gleaning each bar's High and Low.
Then, I would retrieve each text Y anchor data point to compare its value to the current bar, High and Low.
To do that, I've come up with the following code:
double HH, LL;
protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
{
if (ChartBars != null)
{
// reverse loop through all of the viewable range of the chart
for (int barIndex = ChartBars.ToIndex; barIndex >= ChartBars.FromIndex; barIndex--)
{
// get the High and Low values for each index within the viewable range
HH = High.GetValueAt(barIndex);
LL = Low.GetValueAt(barIndex);
foreach (DrawingTool draw in DrawObjects.ToList())
{
// Find text objects that are attached to the chart
if (draw is DrawingTools.Text)
{
DrawingTools.Text msg = draw as DrawingTools.Text;
if (HH > msg.Y || LL < msg.Y) msg.Brush = Brushes.Gray;
}
}
}
}
}
Is there any hidden error in the above code?
What about checking all the bars, not just those rendered on the ChartPanel?
Or is there even a better way?

Comment