Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Draw Line thru tomorrow

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

    Draw Line thru tomorrow

    Hi All,

    How do I draw a line that starts today say at 9 pm and goes thru to tomorrow 8 am?

    My draw line statement is as follows:

    DrawLine(HighLine.ToString(), false, StartTime, HH, EndTime, HH, Color.Green, DashStyle.Solid, 2);

    Where StartTime & EndTime are:

    StartTime = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, 21, 00, 0);
    EndTime = new DateTime(Time[0].Year, Time[0].Month, Time[0].Day, 8, 00, 0);

    It works just fine when I want it to draw lines from say 8 am to 11 am. But from the night session thru the day session, it draws the line from 8 am of the current day to 9 pm of the current day as oppose to from 9 pm of current day to 8 am of the following day.

    All help is greatly appreciated.

    #2
    Hello GeoOrtiz,

    I believe the problem is that you are using the same day for start and end times. I believe changing this line

    Code:
    EndTime = new DateTime(Time[0].Year, Time[0].Month, Time[0].[B]Day[/B], 8, 00, 0);
    to this

    Code:
    EndTime = new DateTime(Time[0].Year, Time[0].Month, Time[0].[B]Day + 1[/B], 8, 00, 0);
    will allow you to see the problem straight away. I recommend comparing StartTime to EndTime, and adding 1 to EndTime if it is before StartTime.

    If you provide a complete code sample, I will be able to assist further.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      Thank you Jessica. The "+ 1" did the trick!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by argusthome, 03-08-2026, 10:06 AM
      0 responses
      79 views
      0 likes
      Last Post argusthome  
      Started by NabilKhattabi, 03-06-2026, 11:18 AM
      0 responses
      45 views
      0 likes
      Last Post NabilKhattabi  
      Started by Deep42, 03-06-2026, 12:28 AM
      0 responses
      29 views
      0 likes
      Last Post Deep42
      by Deep42
       
      Started by TheRealMorford, 03-05-2026, 06:15 PM
      0 responses
      32 views
      0 likes
      Last Post TheRealMorford  
      Started by Mindset, 02-28-2026, 06:16 AM
      0 responses
      65 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Working...
      X