Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Get color from Text drawn by indicator

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Get color from Text drawn by indicator

    Hello guys,

    I would like to know how I can extract the text color by a Text object drawn from an external indicator loaded on chart.
    I understand I can loop all drawn objects with this code:

    foreach (DrawingTool draw in DrawObjects.ToList())
    {
    if(draw.Name == "Text") Print(draw.Tag)
    }

    But I would like to also restrict that the text object was drawn by a specific color. For example: White text color.

    Thank you.

    #2
    Hello facuevasm,

    Thanks for your post.

    If you need a specific property from a specific type of object you would need to cast to that object in your script and then you could access the specific property, such as the TextBrush property of that drawing object by using something like myDrawText.TextBrush.

    For example, see below.

    Code:
    foreach (DrawingTool draw in DrawObjects.ToList())
    {
        if (draw is DrawingTools.Text)
        { 
            DrawingTools.Text myDrawText = draw as DrawingTools.Text;
    
            Print("Text object: " + myDrawText.Tag + " TextBrush: " + myDrawText.TextBrush);
        }
    }
    See the 'Looping through the collection to find specific draw objects' section of this help guide page for more sample code: https://ninjatrader.com/support/help...rawobjects.htm

    Let us know if we may assist further.
    Brandon H.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by AaronKoRn, Today, 09:49 PM
    0 responses
    7 views
    0 likes
    Last Post AaronKoRn  
    Started by carnitron, Today, 08:42 PM
    0 responses
    9 views
    0 likes
    Last Post carnitron  
    Started by strategist007, Today, 07:51 PM
    0 responses
    10 views
    0 likes
    Last Post strategist007  
    Started by StockTrader88, 03-06-2021, 08:58 AM
    44 responses
    3,980 views
    3 likes
    Last Post jhudas88  
    Started by rbeckmann05, Today, 06:48 PM
    0 responses
    9 views
    0 likes
    Last Post rbeckmann05  
    Working...
    X