Announcement

Collapse
No announcement yet.

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.

    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.

      Comment


        #4
        Thanks much Chris!

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        633 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        364 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
        567 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        568 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X