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 andrewtrades, Today, 04:57 PM
    1 response
    5 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by chbruno, Today, 04:10 PM
    0 responses
    3 views
    0 likes
    Last Post chbruno
    by chbruno
     
    Started by josh18955, 03-25-2023, 11:16 AM
    6 responses
    436 views
    0 likes
    Last Post Delerium  
    Started by FAQtrader, Today, 03:35 PM
    0 responses
    6 views
    0 likes
    Last Post FAQtrader  
    Started by rocketman7, Today, 09:41 AM
    5 responses
    19 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X