• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Backtest start date from Onstartup

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

    Backtest start date from Onstartup

    Hi,

    My strategy's initial state depends on which date it starts on, so it needs to know what that date is before trading. How can I get the simulation start date before the simulation starts (from oninitialize or on startup)?

    #2
    benoirat, I would just look into Time[0].Date accessed from OnStartUp(), that's basically CurrentBar == 0 then.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      The problem is Time does not seem to be initiated in onstartup.

      Code:
      DateTime startDate = Time[0];
      
      ==> error:
      Bar index needs to be greater/equal 0

      Comment


        #4
        Cannot reproduce here, which BarsRequired do you use for your script?
        BertrandNinjaTrader Customer Service

        Comment


          #5
          Indeed I had set 0. With 1 it works fine.

          Thanks a lot.

          Comment


            #6
            Ok, great.
            BertrandNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Sannyttaffaw, Today, 04:14 AM
            0 responses
            3 views
            0 likes
            Last Post Sannyttaffaw  
            Started by canuck, Yesterday, 07:52 PM
            0 responses
            6 views
            0 likes
            Last Post canuck
            by canuck
             
            Started by itrader46, 10-21-2019, 11:12 PM
            2 responses
            20 views
            0 likes
            Last Post koganam
            by koganam
             
            Started by walter739, Yesterday, 06:04 PM
            0 responses
            4 views
            0 likes
            Last Post walter739  
            Started by MarkWise, Yesterday, 03:04 PM
            2 responses
            9 views
            0 likes
            Last Post MarkWise  
            Working...
            X