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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        54 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        29 views
        0 likes
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        40 views
        1 like
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        56 views
        0 likes
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        47 views
        0 likes
        Last Post CarlTrading  
        Working...
        X