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 helpwanted, Today, 03:06 AM
            1 response
            10 views
            0 likes
            Last Post sarafuenonly123  
            Started by Brevo, Today, 01:45 AM
            0 responses
            9 views
            0 likes
            Last Post Brevo
            by Brevo
             
            Started by aussugardefender, Today, 01:07 AM
            0 responses
            5 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
            387 views
            1 like
            Last Post Gavini
            by Gavini
             
            Working...
            X