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

Draw.Ray - Way to limit length?

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

    Draw.Ray - Way to limit length?

    Hi,

    I'm using Draw.Ray as it is the easiest way for me to project the plotted line a few bars into the future at the correct scale. For aesthetic reasons though, I'd rather limit the length. I can't see a way to do this. Is this possible?

    Alternatively, does anyone have a code snippet for drawing a line through 2 points, where the end point is NOT the end value, so it can project a few bars into the future, with the correct scale etc? I took a look, but the code for the Ray drawing tool does not seem to be one of the public codes supplied.

    Thanks.

    #2
    Hello pjsmith,

    Thank you for the post.

    I am unaware of any way to limit the length of the ray as it is intended to extend currently. The logic the ray uses to calculate the projection would likely be needed to accomplish your alternative to correctly account for scale etc as you pointed out.

    I will need to question development to see if they can disclose any details surrounding how that method works. Once I have more details surrounding how to accomplish that, i will reply back here.

    If the logic to do this cannot be reused, I will put in a feature request to have a variable length rendered past the second anchor.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hello pjsmith,

      I just wanted to reply back, development got back to me and provided some direction on what would be needed to create a projection. The internal method can still be used in your NinjaScript files, the internal logic does not need to be seen to accomplish this.

      I have attached a sample that first draws a Ray then takes the Points from the ray and creates a projection. I tried to comment the file as best I could, the logic to do this is complicated. I also setup some properties to control the test script and make it more easily readable. The ProjectionLength property shows where in the logic the projection points are configured and later calculated.

      In the sample the lime line is the ray which extends off the canvas, the red line is the rendered projection which does not extend off the canvas.


      I look forward to being of further assistance.
      Attached Files
      JesseNinjaTrader Customer Service

      Comment


        #4
        Thank you for this. I think I'll be able to modify that method to my needs. Much appreciated.

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by CortexZenUSA, Today, 12:53 AM
        0 responses
        1 view
        0 likes
        Last Post CortexZenUSA  
        Started by CortexZenUSA, Today, 12:46 AM
        0 responses
        1 view
        0 likes
        Last Post CortexZenUSA  
        Started by usazencortex, Today, 12:43 AM
        0 responses
        5 views
        0 likes
        Last Post usazencortex  
        Started by sidlercom80, 10-28-2023, 08:49 AM
        168 responses
        2,265 views
        0 likes
        Last Post sidlercom80  
        Started by Barry Milan, Yesterday, 10:35 PM
        3 responses
        12 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Working...
        X