I am trying find the best way to find the color of an object that has been plotted by an indicator.
I've been using the example from this post: https://forum.ninjatrader.com/forum/...arty-indicator
It works great for most indicators using 'Text'.
However, I'm having an issue with certain 3rd party indicators that appear to also use 'Text' but the example code does not recognize them. I modified the code from the link to DrawingTools.DrawingTool instead of DrawingTools.Text and it seems to read these 3rd party objects now. But I lost the ability to display the Brush color code. (I may be missing something obvious here)
Original Code from Link:
protected override void OnBarUpdate() { foreach (DrawingTool draw in DrawObjects.ToList()) { if (draw is DrawingTools.Text) { if (draw.Tag == "Text1") { DrawingTools.Text temp = draw as DrawingTools.Text; Print("startTime: " + temp.Anchor.Time + " Y axis" + temp.Anchor.Price); Print("text: " + temp.DisplayText); Print("Font: " + temp.Font.Family); Print("Color" + temp.TextBrush); } } } }
protected override void OnBarUpdate() { foreach (DrawingTool draw in DrawObjects.ToList()) { if (draw is DrawingTools.DrawingTool) { if (draw.Tag == "Text1") { DrawingTools.DrawingTool temp = draw as DrawingTools.DrawingTool; ///Cannot use these below //Print("startTime: " + temp.Anchor.Time + " Y axis" + temp.Anchor.Price); //Print("text: " + temp.DisplayText); //Print("Font: " + temp.Font.Family); //Print("Color" + temp.TextBrush); } } } }
if (DrawObjects["IndicatorDrawingTag"+ CurrentBar] != null && *IndicatorColor == MyColor* )
{
//Do Something;
}
Hope this makes sense. Please let me know what the best way would be to find the color from these indicators.
Thank you in advance!
Comment