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

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 GussJ, 03-04-2020, 03:11 PM
        15 responses
        3,270 views
        0 likes
        Last Post xiinteractive  
        Started by Tim-c, Today, 02:10 PM
        1 response
        8 views
        0 likes
        Last Post NinjaTrader_ChelseaB  
        Started by Taddypole, Today, 02:47 PM
        0 responses
        2 views
        0 likes
        Last Post Taddypole  
        Started by chbruno, 04-24-2024, 04:10 PM
        4 responses
        51 views
        0 likes
        Last Post chbruno
        by chbruno
         
        Started by TraderG23, 12-08-2023, 07:56 AM
        10 responses
        403 views
        1 like
        Last Post beobast
        by beobast
         
        Working...
        X