Announcement

Collapse
No announcement yet.

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 Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    605 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    351 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    105 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    560 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    561 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X