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

Rayline value calculation

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

    Rayline value calculation

    Hi,

    I use a strategy code to automatically draw ray lines based on certain reversal bars.
    Here is a function I use to draw that ray line:

    ...
    DrawRay("HighEndLine", false, hX2, H2, hX1, H1, Color.Blue, DashStyle.Dash, 2);
    ...

    How could I calculate the exact ray line value at any later bar location, as illustrated below?

    Thanks!
    Attached Files

    #2
    where are the 2 anchor points H1 and H2 exactly located in the image ?

    I'm thinking something like :

    1) calculate slope of RayLine
    (H2 - H1) / ( hX1 - hX2 )

    2) calculate distance between anchorbarsago1 and currentbar:
    CurrentBar - hX2

    combining 1 and 2 : multiply slope of Rayline by distance and add to Anchor 1 Y-value
    (H2 - H1) / ( hX1 - hX2 ) * (CurrentBar - hX2) + H2

    this will be the Y-value of the RayLine at CurrentBar.
    does that work ?


    Marco

    Comment


      #3
      Hi Marco

      Thanks for a suggestion. Yes, mathematically it seems to work, but I was just wondering if there were any straight forward function to calculate the ray line value at later bars (than 2 anchor point bars).

      Attached an updated chart pic with marked anchor points/bars.
      Attached Files

      Comment


        #4
        gain,

        Unfortunately we do not have a support NinjaScript function to obtain this information.

        As marco suggested, you would need to calculate the slope, and then the distance between that specific bar and where the ray started to determine the exact Y value of the line at that bar.
        MatthewNinjaTrader Product Management

        Comment


          #5
          Ok, thanks Matthew

          It's no problem to use math to calculate the value, but it sure would be nice to have a chart line values by bar supported natively by Ninjascript, like indicator plot values are. Maybe into a wishlist... ;-)

          Thanks!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by andrewtrades, Today, 04:57 PM
          1 response
          8 views
          0 likes
          Last Post NinjaTrader_Manfred  
          Started by chbruno, Today, 04:10 PM
          0 responses
          6 views
          0 likes
          Last Post chbruno
          by chbruno
           
          Started by josh18955, 03-25-2023, 11:16 AM
          6 responses
          436 views
          0 likes
          Last Post Delerium  
          Started by FAQtrader, Today, 03:35 PM
          0 responses
          7 views
          0 likes
          Last Post FAQtrader  
          Started by rocketman7, Today, 09:41 AM
          5 responses
          19 views
          0 likes
          Last Post NinjaTrader_Jesse  
          Working...
          X