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 Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        579 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        334 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        101 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        554 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        551 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X