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 AttiM, 02-14-2024, 05:20 PM
    12 responses
    213 views
    0 likes
    Last Post DrakeiJosh  
    Started by cre8able, 02-11-2023, 05:43 PM
    3 responses
    238 views
    0 likes
    Last Post rhubear
    by rhubear
     
    Started by frslvr, 04-11-2024, 07:26 AM
    8 responses
    117 views
    1 like
    Last Post NinjaTrader_BrandonH  
    Started by stafe, 04-15-2024, 08:34 PM
    10 responses
    47 views
    0 likes
    Last Post stafe
    by stafe
     
    Started by rocketman7, Today, 09:41 AM
    3 responses
    13 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Working...
    X