Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Calculate the next working day on a tick chart.

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

    Calculate the next working day on a tick chart.

    I'm coding an indicator for a 2000 tick chart of the ES. I split the trading day into two sessions: one corresponding to the trading hours of the NYSE cash market, namely from 9:30 AM to 4:15 PM EST, and the second for the remaining time. I call the first one the RTH session and the latter the ETH session or overnight.

    Then, I calculate the extremes of each session, the highest high and the lowest low. Once I got these values, obviously only at the last bar of each session, I wanted to draw a straight line at these levels from the beginning of the next RTH session until its end. I have no problem when the overnight session ends because I only need to stretch the past ETH levels to 4:15 on the same day.

    The problem arises with the RTH levels since I want to draw them on the RTH portion of the next working day, considering both holidays and weekends. I looked at the Session Iterator pages of the documentation, but I couldn't find a solution. The time granularity of a tick chart is not the same as a time-based chart like a 30-minute chart. I need a calendar calculator. I glimpsed at .NET documentation about DateTime objects but got more confused—the same with NinjaScript documentation about the trading hours templates. I'm sure there's a way, but how?​

    #2
    Hello Gianpiero,

    If you are trying to draw something on the next day you could use a variable to mark that you have a stored value that needs drawn, then when OnBarUpdate is called for the RTH next, draw it. You shouldn't need to calculate any dates for that purpose, you would just be relying on the order of bar processing which the next time there is a bar processed in RTH it would be the next working day. At that point you could use the session iterator and the bar time to find out the session information for that new day if needed.

    Comment


      #3
      Thank you! I will consider your suggestion, though I'd instead appreciate a more thorough clarification about using the Session Iterator to find out the session information.

      Comment


        #4
        Hello Gianpiero,

        You can find an example of how to use the session iterator in the help guide. You need to pass a valid bar time in to get the session information. If the next session has not yet occurred you would need to make a DateTime of your own if you wanted to find out what the session is for that datetime. That would assume you know what the next trading day is.

        Comment


          #5
          Thank again! I succeeded by following your advice to store values in the last Bar of the RTH session and plot them in the first bar of a new RTH session.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          598 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          343 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          103 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          557 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          557 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X