• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Price crossing a line

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

    Price crossing a line

    Hello

    Is there a way to know if the current price crossed a line which was drawn by gui or from Draw.Line?

    Thanks

    #2
    Hello kiss987,

    Thanks for your post.

    Yes, you would need to loop through a collection of draw objects and determine which line(s) you wanted to check the price against, obtain the anchor prices of the line and compare price to the anchor price.

    Please see this section of the helpguide for sorting through a draw objects collection: https://ninjatrader.com/support/help...rawobjects.htm
    PaulNinjaTrader Customer Service

    Comment


      #3
      Assuming the object named "draw" of type DrawingTools.Line is my line, how do I know its value at barsAgo = 0 (current time)?

      Thanks

      Comment


        #4
        Hello kiss987,

        Thanks for your reply.

        If the line is a horizontal line type then you would only need the start anchor price as the price level does not change for the length of the line

        If the line is a line (which can be of any length and any direction) then you would need to obtain the Start anchor price and bar and the end anchor price and bar, then extend mathematically a projection of the line to the current bar to then calculate the lines price at that bar.
        PaulNinjaTrader Customer Service

        Comment


          #5
          Hello

          How can I extend mathematically a projection of the line (which can be of any length and any direction) to the current bar to then calculate the lines price at that bar?

          Thank you

          Comment


            #6
            Hello kiss987,

            Thanks for your reply.

            You would determine the slope of the line based on the start and end anchor bars and the start and end anchor prices and then use the slope to project what the Y value would be at X location.

            I've attached an example script that draws a ray (for visual purposes) then calculates its slope and projects where the Y value would be for each subsequent bar by plotting a dot on the ray.
            Attached Files
            PaulNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by supermht, Today, 07:59 PM
            0 responses
            2 views
            0 likes
            Last Post supermht  
            Started by mohdhm, Today, 05:13 PM
            1 response
            12 views
            0 likes
            Last Post nkhoi
            by nkhoi
             
            Started by 3lliot, Today, 05:55 PM
            0 responses
            2 views
            0 likes
            Last Post 3lliot
            by 3lliot
             
            Started by Fargo, Today, 04:57 PM
            0 responses
            11 views
            0 likes
            Last Post Fargo
            by Fargo
             
            Started by Johnny Santiago, Today, 03:57 PM
            0 responses
            10 views
            0 likes
            Last Post Johnny Santiago  
            Working...
            X