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

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.
    Kate W.NinjaTrader Customer Service

    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.
        Kate W.NinjaTrader Customer Service

        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.

            Gaby V.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by yertle, Today, 12:24 PM
            0 responses
            2 views
            0 likes
            Last Post yertle
            by yertle
             
            Started by reekotubbs, Yesterday, 01:09 PM
            3 responses
            26 views
            0 likes
            Last Post reekotubbs  
            Started by Blaze212, 07-07-2024, 08:58 PM
            2 responses
            18 views
            0 likes
            Last Post Blaze212  
            Started by medicmiked, Today, 11:56 AM
            0 responses
            2 views
            0 likes
            Last Post medicmiked  
            Started by miaolivi9, Today, 06:59 AM
            0 responses
            8 views
            0 likes
            Last Post miaolivi9  
            Working...
            X