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 CarlTrading, 03-31-2026, 09:41 PM
    1 response
    81 views
    1 like
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 04-01-2026, 02:41 AM
    0 responses
    42 views
    0 likes
    Last Post CarlTrading  
    Started by CaptainJack, 03-31-2026, 11:44 PM
    0 responses
    64 views
    2 likes
    Last Post CaptainJack  
    Started by CarlTrading, 03-30-2026, 11:51 AM
    0 responses
    66 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 03-30-2026, 11:48 AM
    0 responses
    54 views
    0 likes
    Last Post CarlTrading  
    Working...
    X