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

Start Date and End Date

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

    Start Date and End Date

    Hi,
    Is it possible to get Start Date and End Date that I set for backtest/optimization within NT strategy?
    The date of the first bar isn't always equals my Start Date because some stocks might have IPO within that range.
    Thanks.

    #2
    Hello Leeroy_Jenkins,

    You could use the From and To properties to find the dates you set in the UI. You would otherwise need to use the Time object to see the actual dates from the data.

    Code:
    Print(From + " " + To);
    
    Print(Time[0]);
    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Hi,
      To my understanding, the date set in the user interface cannot be iterated through in an optimization.
      But perhaps this here is helpful?
      https://ninjatrader.com/support/foru...of-instruments
      You might be able to use this concept and can perhaps even eloborate it further. You could add FromToDate variables by instrument setting the allowed date window.
      Example: Instrument1 only between Instrument1From and Instrument1To.
      With that, you can even correctly backtest strategies for instruments in an index using the correct index composition at any point in time, eliminating the "survivorship bias".
      NT-Roland

      Comment


        #4
        Originally posted by NT-Roland View Post
        To my understanding, the date set in the user interface cannot be iterated through in an optimization.
        NT-Roland
        What you're trying to do is beyond my understanding. Testing window is always should be reasonable and more importantly fixed. I don't know about you but comparing results from one stock with XX testing years and another stock with YY years doesn't make sense to me. It doesn't give you "stability" of a system.

        Comment


          #5
          Hi Leeroy_Jenkins,
          I tried to offer a solution to your question.
          "Is it possible to get Start Date and End Date that I set for backtest/optimization within NT strategy?
          The date of the first bar isn't always equals my Start Date because some stocks might have IPO within that range."

          What I suggested should allow you to exclude whatever time frame you want for individual stocks even if the overall range is not narrowed down.

          And the "survivorship bias" is a serious issue for all traders which test strategies against all instruments of a certain index, but don't pay attention to the fact that they test its current members only. The difference between fake and real performance is significant. One recent example? Imagine, you wanted to trade all DAX30 stocks, if they met some other conditions. Would you have invested in Wirecard? Likely Yes. And that one went bankrupt and was eliminated from the DAX30. Thus, if you backtest the DAX 30 strat NOW for let's say 10 years applying the current index composition, which obviously doesn't include Wirecard anymore, you trick yourself big time. Thus, it does make perfect sense to backtest against ALL instruments that have ever been in the respective index, but limit the trading time for each of them to the time they really were part of the index. Only then, you get reliable results.
          Other platforms offer that out of the box. In Ninja, you have to get your hands dirty.
          NT-Roland

          Comment


            #6
            Hi I was trying to open the link given by NT_Roland
            Hello. I am working with a half dozen different instruments and have a custom strategy and optimizer with has a bunch of parameters that I'm trying to optimize. >> Is it possible for me to do one run and vary the date period in a single run? Essentially, I'd like to set Strategy.To and .From just like I set


            but got a message saying " you are being rate limited by owner of this website ...."

            I am signed into the support forum - can you please tell how to access the link
            thanks
            Suraj

            Comment


              #7
              Just paste to the address bar:
              forum.ninjatrader.com/forum/ninjatrader-8/strategy-development/1155279-optimize-with-different-date-ranges-or-a-list-of-instruments

              Also try other browser or even VPN. Seems like Cloudflare doesn't wanna let you go.
              Last edited by Leeroy_Jenkins; 09-16-2023, 11:56 PM.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by bortz, 11-06-2023, 08:04 AM
              47 responses
              1,608 views
              0 likes
              Last Post aligator  
              Started by jaybedreamin, Today, 05:56 PM
              0 responses
              9 views
              0 likes
              Last Post jaybedreamin  
              Started by DJ888, 04-16-2024, 06:09 PM
              6 responses
              19 views
              0 likes
              Last Post DJ888
              by DJ888
               
              Started by Jon17, Today, 04:33 PM
              0 responses
              6 views
              0 likes
              Last Post Jon17
              by Jon17
               
              Started by Javierw.ok, Today, 04:12 PM
              0 responses
              16 views
              0 likes
              Last Post Javierw.ok  
              Working...
              X