Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Vertical Lines at sessions

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

    Vertical Lines at sessions

    I'd like to create an indicator the plots red vertical lines at specific times. This is what I've got so far. Where I'm stuck is to how to create the lines for the rest of the days moving forward. Thank you in advance for the help.


    protected override void OnBarUpdate()
    {
    Draw.RegionHighlightY(this, "tag1", false, High[0], Low[0], Brushes.Goldenrod, Brushes.Goldenrod, 25)
    DateTime thisDay = Bars.GetTime(0);
    int year = thisDay.Year;
    int month = thisDay.Month;
    int day = thisDay.Day;
    DateTime treasuryOpen = new DateTime(year, month, day, 7, 20, 0);
    DateTime treasuryClose = new DateTime(year, month, day, 14, 0, 0);
    DateTime stocksOpen = new DateTime(year, month, day, 8, 30, 0);
    DateTime stocksClose = new DateTime(year, month, day, 15, 00, 0);
    Draw.VerticalLine(this, "tag2", treasuryOpen, Brushes.Red);
    Draw.VerticalLine(this, "tag3", treasuryClose, Brushes.Red);
    }

    Attached Files

    #2
    Hello edmata1109,

    Are there other specific dates you want to add a condition for?

    Or is there a rule for drawing the lines every month?

    Below is a link to a forum post with helpful information about getting started with NinjaScript.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Chelsea,

      Thank you for your reply. I specifically want to add these vertical lines on a daily basis. At 07:20 and 14:00. These are the CBOT outcry hours for the treasury futures.

      Thank you,

      Edgar

      Comment


        #4
        Hello Edgar,

        You can use conditions to draw objects or trigger other actions at specific times.

        Below is a link to an example of a time filter.


        And a link to the Strategy Builder 301 which discusses time objects.


        When the time of the bar is equal to a specific time or between to times, draw an object on the current bar.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Mindset, 04-21-2026, 06:46 AM
        0 responses
        52 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        71 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        38 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        99 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        60 views
        0 likes
        Last Post PaulMohn  
        Working...
        X