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 GussJ, 03-04-2020, 03:11 PM
            11 responses
            3,227 views
            0 likes
            Last Post xiinteractive  
            Started by andrewtrades, Today, 04:57 PM
            1 response
            13 views
            0 likes
            Last Post NinjaTrader_Manfred  
            Started by chbruno, Today, 04:10 PM
            0 responses
            7 views
            0 likes
            Last Post chbruno
            by chbruno
             
            Started by josh18955, 03-25-2023, 11:16 AM
            6 responses
            440 views
            0 likes
            Last Post Delerium  
            Started by FAQtrader, Today, 03:35 PM
            0 responses
            12 views
            0 likes
            Last Post FAQtrader  
            Working...
            X