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 CarlTrading, 03-31-2026, 09:41 PM
        1 response
        115 views
        1 like
        Last Post NinjaTrader_ChelseaB  
        Started by CarlTrading, 04-01-2026, 02:41 AM
        0 responses
        66 views
        1 like
        Last Post CarlTrading  
        Started by CaptainJack, 03-31-2026, 11:44 PM
        0 responses
        101 views
        2 likes
        Last Post CaptainJack  
        Started by CarlTrading, 03-30-2026, 11:51 AM
        0 responses
        91 views
        1 like
        Last Post CarlTrading  
        Started by CarlTrading, 03-30-2026, 11:48 AM
        0 responses
        78 views
        0 likes
        Last Post CarlTrading  
        Working...
        X