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 alifarahani, Today, 09:40 AM
        6 responses
        36 views
        0 likes
        Last Post alifarahani  
        Started by Waxavi, Today, 02:10 AM
        1 response
        17 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Started by Kaledus, Today, 01:29 PM
        5 responses
        14 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Started by Waxavi, Today, 02:00 AM
        1 response
        12 views
        0 likes
        Last Post NinjaTrader_LuisH  
        Started by gentlebenthebear, Today, 01:30 AM
        3 responses
        17 views
        0 likes
        Last Post NinjaTrader_Jesse  
        Working...
        X