Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to Iterate through user drawn vertical lines and get their properties

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

    How to Iterate through user drawn vertical lines and get their properties

    What's the syntax for iterating through the user drawn vertical lines on a chart to print the tags, and horizontal locations. of all of those lines?
    Have been able to get the tags, but not the locations, either as date times or bar numbers.
    Thanks in advance.

    #2
    Hello Ricam,

    Thanks for your post.

    For an example, please see the help guide here: https://ninjatrader.com/support/help...rawobjects.htm

    The 2nd example provides a clue on how to access the anchor points.

    I don't have an example for vertical lines but perhaps this one for rectangles will help:

    Code:
     if (DrawObjects.Count > 0)
    {
    foreach (DrawingTool draw in DrawObjects.ToList())
    {
    if (draw is DrawingTools.Rectangle )
    {
    Print ("Tag name: "+draw.Tag);
    DrawingTools.Rectangle temp = draw as DrawingTools.Rectangle;
    
    Print("startYPrice: " + temp.StartAnchor.Price);
    Print("startXTime: " + temp.StartAnchor.Time);
    Print("startXBarsAgo: " + (CurrentBar - temp.StartAnchor.SlotIndex));
    Print("endYPrice: " + temp.EndAnchor.Price);
    Print("endXTime: " + temp.EndAnchor.Time);
    Print("endXbarsago: " + (CurrentBar - temp.EndAnchor.SlotIndex));
    }
    }
    }

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    68 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    150 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    162 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    100 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    288 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Working...
    X