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 BarzTrading, Today, 07:25 AM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_Clayton  
        Started by EB Worx, 04-04-2023, 02:34 AM
        7 responses
        161 views
        0 likes
        Last Post VFI26
        by VFI26
         
        Started by Mizzouman1, Today, 07:35 AM
        1 response
        9 views
        0 likes
        Last Post NinjaTrader_Gaby  
        Started by Radano, 06-10-2021, 01:40 AM
        20 responses
        616 views
        0 likes
        Last Post NinjaTrader_BrandonH  
        Started by i019945nj, 12-14-2023, 06:41 AM
        6 responses
        68 views
        0 likes
        Last Post i019945nj  
        Working...
        X