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