Read Text drawing object from chart

I am trying to write a strategy that will do something based on reading a text object that is drawn on the chart. I’m having trouble getting it to read the actual text drawn on the chart. I cannot figure out how to get this set. Here is a snippet of the code…

protected override void OnBarUpdate()
{
if (BarsInProgress != 0)
return;

foreach (DrawingTool draw in DrawObjects.ToList())
{
if (draw is DrawingTools.Text)
{
// Indicates if this is a manually drawn or script generated line
Print("Text is: " + draw);
}
}

This is what I’m getting in the output window

Text is: NinjaTrader.NinjaScript.DrawingTools.Text

I think your problem is due to is operator.

It evaluates to true if the object referenced by draw is an instance of the DrawingTools.Text class (or a subclass of it).

Thanks for the reply. I guess I’ll give up on it, I don’t know what needs to be changed to get it to get the actual text…

I believe this should work for you and is more portable.

foreach (IDrawingTool draw in DrawObjects.ToList())
{
	if (draw.ToString().Equals("NinjaTrader.NinjaScript.DrawingTools.Text"))
	{
		NinjaTrader.NinjaScript.DrawingTools.Text dt = draw as NinjaTrader.NinjaScript.DrawingTools.Text;
		Print(dt.DisplayText);
	}
}

That worked! thank you