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 Brevo, Today, 01:45 AM
        0 responses
        6 views
        0 likes
        Last Post Brevo
        by Brevo
         
        Started by aussugardefender, Today, 01:07 AM
        0 responses
        3 views
        0 likes
        Last Post aussugardefender  
        Started by pvincent, 06-23-2022, 12:53 PM
        14 responses
        242 views
        0 likes
        Last Post Nyman
        by Nyman
         
        Started by TraderG23, 12-08-2023, 07:56 AM
        9 responses
        384 views
        1 like
        Last Post Gavini
        by Gavini
         
        Started by oviejo, Today, 12:28 AM
        0 responses
        6 views
        0 likes
        Last Post oviejo
        by oviejo
         
        Working...
        X