Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Get the color of the drawing objects

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

    Get the color of the drawing objects

    Hi, there is a way to get the color of the drawing objects in the chart, for example following this code i get the anchors of the rectangle but i need get the color too

    if (draw is DrawingTools.Line)
    {

    DrawingTools.Line LineTemp = draw as DrawingTools.Line;
    LineTag = draw.Tag;


    if (draw.GetType().Name == "ArrowLine")
    {
    LineStartPrice = LineTemp.StartAnchor.Price;
    LineEndPrice = LineTemp.EndAnchor.Price;
    LineStartTime = LineTemp.StartAnchor.Time;
    LineEndTime = LineTemp.EndAnchor.Time;
    }

    if (draw.GetType().Name == "Line")
    {
    LineStartPrice = LineTemp.StartAnchor.Price;
    LineEndPrice = LineTemp.EndAnchor.Price;
    LineStartTime = LineTemp.StartAnchor.Time;
    LineEndTime = LineTemp.EndAnchor.Time;
    }
    }​
    Last edited by MJGutierrez; 11-29-2022, 12:08 AM.

    #2
    Hello MJGutierrez,

    Thank you for your post.

    Both ArrowLine and Line objects have a Stroke which contains the stroke object with the brush used to draw the object. For example, the following snippet would print the color used for myLine:

    Code:
    private NinjaTrader.NinjaScript.DrawingTools.Line myLine;
    ​
    protected override void OnBarUpdate()
    {
    if (State == State.Historical)
    return;
    myLine = Draw.Line(this, "tag", 15, Close[15], 0, Close[0], Brushes.Red);
    Print("myLine brush:" + myLine.Stroke.Brush);
    }


    For more information, please see the following help guide pages:




    Please let us know if we may be of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    566 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    330 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    547 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    548 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X