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

Drawline(Price/bar, Time)

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

    Drawline(Price/bar, Time)

    Hello,

    In a NinjaTrader 7 script, I want to use DrawLine starting with a condition on a bar, eg Close[0] > priordayClose and ending the line eg at 15:30 time.

    I searched the forum and could not find a solution.

    Thank you

    #2
    Hello,

    Thank you for the post.

    I am reviewing your inquiry and will be back with a reply shortly.

    I look forward to assisting further.
    Chris L.NinjaTrader Customer Service

    Comment


      #3
      Hello jackomulligan,

      Thank you for your patience and welcome to the forum.

      You will get the prior day close with PriorDayOHLC():

      Code:
      double value = PriorDayOHLC().PriorClose[0];
      More on PriorDayOHLC():


      Then you will use DrawLine() to draw the line based on the data:



      For example:

      Code:
      protected override void OnBarUpdate()
              {
                  if (ToTime(Time[0]) < ToTime(15, 30, 0)
      				&& Close[0] > PriorDayOHLC().PriorClose[0])
      			{
      				DateTime endTime = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, 15, 30, 0);
      				DrawLine(Time[0].Date.ToString(), true, Time[0], Close[0], endTime, Close[0], Color.LimeGreen, DashStyle.Solid, 3);
      			}
              }
      This will draw a line from the current day's bar when it closes above the prior day close and then to the current day's 3:30 pm.

      If there is anything else I may assist with please let me know.
      Chris L.NinjaTrader Customer Service

      Comment


        #4
        Thanks much Chris!

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by judysamnt7, 03-13-2023, 09:11 AM
        4 responses
        59 views
        0 likes
        Last Post DynamicTest  
        Started by ScottWalsh, Today, 06:52 PM
        4 responses
        36 views
        0 likes
        Last Post ScottWalsh  
        Started by olisav57, Today, 07:39 PM
        0 responses
        7 views
        0 likes
        Last Post olisav57  
        Started by trilliantrader, Today, 03:01 PM
        2 responses
        21 views
        0 likes
        Last Post helpwanted  
        Started by cre8able, Today, 07:24 PM
        0 responses
        10 views
        0 likes
        Last Post cre8able  
        Working...
        X