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.

    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?

        Comment


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

          Thanks a lot.

          Comment


            #6
            Ok, great.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by argusthome, 03-08-2026, 10:06 AM
            0 responses
            85 views
            0 likes
            Last Post argusthome  
            Started by NabilKhattabi, 03-06-2026, 11:18 AM
            0 responses
            48 views
            0 likes
            Last Post NabilKhattabi  
            Started by Deep42, 03-06-2026, 12:28 AM
            0 responses
            29 views
            0 likes
            Last Post Deep42
            by Deep42
             
            Started by TheRealMorford, 03-05-2026, 06:15 PM
            0 responses
            32 views
            0 likes
            Last Post TheRealMorford  
            Started by Mindset, 02-28-2026, 06:16 AM
            0 responses
            67 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Working...
            X