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

Automatically Plot Ray

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

    Automatically Plot Ray

    Hello,

    What is the code to automatically plot a ray that begins when the 9:30 AM bar closes and stretches to the following day at the close of the 9:30 AM bar?

    Also, how would I apply that code into Ninja Trader so that it appears as an "Indicator"?

    Thanks.
    Eric

    #2
    Hello,

    Thank you for writing in today. You can accomplish this by either setting an indicator plot during the specified timeframe, or by calling the DrawLine() method during the specified timeframe.

    One thing to note -- a ray is a drawing object with a fixed start point which extends infinitely in one direction, so you will need to use a line if you want a fixed start and end point.

    You can use the ToTime() method to determine the current time, and create properties to be able to change the start and end time in the Indicators window. You will need to test two separate conditions -- one to determine whether the day is the same day that the indicator was initialized and whether the time is after the specified start time, and another to determine whether the day is the day after the indicator was initialized and whether the time is before the specified end time.

    In order to ensure that the line is always fixed at the same Y value without disappearing from the chart or messing with the auto-scaling, I recommend creating a Y-Value property that can be manually changed in the Indicators window. Alternatively, if you would like the line to appear in a separate chart panel to avoid this, you can set the indicator plot instead of drawing a line.

    I've created a brief sample to illustrate this process in action, and uploaded it to this post.

    Please see the help guide links below for more information on the important methods and classes used in the sample:

    DateTime Objects: https://msdn.microsoft.com/en-us/lib...vs.110%29.aspx

    ToTime(): http://www.ninjatrader.com/support/h...tml?totime.htm

    DrawLine(): http://www.ninjatrader.com/support/h...l?drawline.htm

    Please let me know if I can assist further.
    Attached Files
    Dave I.NinjaTrader Product Management

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by bortz, 11-06-2023, 08:04 AM
    47 responses
    1,604 views
    0 likes
    Last Post aligator  
    Started by jaybedreamin, Today, 05:56 PM
    0 responses
    8 views
    0 likes
    Last Post jaybedreamin  
    Started by DJ888, 04-16-2024, 06:09 PM
    6 responses
    18 views
    0 likes
    Last Post DJ888
    by DJ888
     
    Started by Jon17, Today, 04:33 PM
    0 responses
    4 views
    0 likes
    Last Post Jon17
    by Jon17
     
    Started by Javierw.ok, Today, 04:12 PM
    0 responses
    13 views
    0 likes
    Last Post Javierw.ok  
    Working...
    X