Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Function to return number of trading days

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

    Function to return number of trading days

    Is there a function that can return the number of trading days between two dates?

    What I really would like is something that returns the number of daily bars between today's date, and some date in the past.

    Any help appreciated!

    #2
    Hello janseun,

    I'm not aware of any method that does this.

    You would need to create custom logic to accomplish this. A loop (which you could do in a custom method) that loops through the previous bars until the date is found (or stops after finding the first bar with a date before the selected date) would be the likely logic needed.

    If you would like we can submit a feature request for the NinjaTrader Development to consider adding this method to a future version of NinjaTrader.
    Would you like to submit a feature request?
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Chelsea

      Thanks for the reply. I see your logic, but the problem I run into is that I don't have all those bars loaded.

      I have a multi-timeframe series, and want to be able to extrapolate the values of trendlines that date back up to a year or so. However, I don't want to have to load a year's worth of data in my main strategy.

      Any other solution you can think of would be welcome!
      Jan

      Comment


        #4
        Hello Jan,

        You could use a sessionIterator, loop through each day, and use IsTradingDayDefined() or IsInSession() to see if its a trading day.


        You could also use a BarsRequest to call the data out of sync.
        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
        574 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        332 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
        553 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