Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Determining price of line, ray, etc. at bar

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

    Determining price of line, ray, etc. at bar

    I see examples of NT7 and I'm trying to translate to NT8 to determine line crossings. I know the slope needs to be calculated but (bar1 = (drawObject as Line).StartAnchor.BarsAgo) is not working for instance.

    I also tried: (bar1 = CurrentBar - (int)line.StartAnchor.SlotIndex to get the BarsAgo.

    What is the correct way to determine the price of a line (user drawn and non user drawn) at a particular bar?

    Thanks in advance.

    #2
    Hello jalley,

    Thank you for your post.

    To determine the price level of a Line, on each bar after the line has been drawn, you would need to project where the line will be. You can do this by using the slope of the line to calculate the run rate. Please see this thread for further information and an example: https://ninjatrader.com/support/foru...-the-drawn-ray

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

    Comment


      #3
      Hi Kate,

      How could this be done for a user drawn line, since the BarsAgo on the anchors can't be used?

      Thank you

      Comment


        #4
        Hello jalley,

        Thank you for your reply.

        You'd need to identify the manually drawn line by looping through the Drawing objects on the chart. You would need to use the Time object from the chart start/end anchor and use GetSlotIndexByTime():

        https://ninjatrader.com/support/help...ndexbytime.htm

        That method will return the bar index of that time. The index counts up from the leftmost bar on the chart. From that data, you can find the price of any bar between the start anchor and the end anchor. You will essentially find the slope of the line in terms of price vs time.

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

        Comment


          #5
          Originally posted by NinjaTrader_Kate View Post
          Hello jalley,

          Thank you for your reply.

          You'd need to identify the manually drawn line by looping through the Drawing objects on the chart. You would need to use the Time object from the chart start/end anchor and use GetSlotIndexByTime():

          https://ninjatrader.com/support/help...ndexbytime.htm

          That method will return the bar index of that time. The index counts up from the leftmost bar on the chart. From that data, you can find the price of any bar between the start anchor and the end anchor. You will essentially find the slope of the line in terms of price vs time.

          Please let us know if we may be of further assistance to you.
          Hi Kate, do you have an example of this?

          Thanks, Bob

          Comment


            #6
            Hello bobperez,

            While we don't have an existing sample of this, the DrawObjects Help Guide page has code demonstrating looping through the Drawing objects on the chart:



            IDrawingTool exposes information about the objects such as tag, if it is user drawn, etc and you can also use ChartAnchor to get the bar index or price of the object.

            Comment

            Latest Posts

            Collapse

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