Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
        Understand the fundamentals of basic strategy creation by developing an actual strategy using the NinjaTrader Strategy Builder.2:45 Opening a Strategy Builde...


        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 zstheorist, Today, 07:52 PM
        0 responses
        3 views
        0 likes
        Last Post zstheorist  
        Started by pmachiraju, 11-01-2023, 04:46 AM
        8 responses
        149 views
        0 likes
        Last Post rehmans
        by rehmans
         
        Started by mattbsea, Today, 05:44 PM
        0 responses
        5 views
        0 likes
        Last Post mattbsea  
        Started by RideMe, 04-07-2024, 04:54 PM
        6 responses
        33 views
        0 likes
        Last Post RideMe
        by RideMe
         
        Started by tkaboris, Today, 05:13 PM
        0 responses
        5 views
        0 likes
        Last Post tkaboris  
        Working...
        X