Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BackTest MinBarsRequired conceptual question

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

    BackTest MinBarsRequired conceptual question

    Hello,

    I want to backtest my strategy for single day, let's do 2jan2009.

    I need BarsBackRequired=200;


    So I start the StrategyAnalyzer , run it and debug, and in

    OnBarUpdate() the first call arrives not at market open of the day , but the first call is 200 bars later.

    Is there a possibility to run the BackTest also starting from mar****pen directly and not 200 bars later?

    A simple fix would be to define the start date of the strategy 200 bars earlier, but 200 bars earliers is not a constant timespan, because there can be weekends, trading holidays , daylight saving time etc. in between.

    So there is no easy way to find the exact timespan for 200 bars before.

    The best would be if the strategy could just start on the datetime defined as SessionBegin and at the same time have also 200 bars more in the Bars object.

    Any idea on how to setup a strategy in this way?

    Andreas

    #2
    Andreas,

    That would not be the usage model for the strategies. I suggest you just load a date further back that is guaranteed to contain your 200 bars and then simply filter your strategy to not process anything until your desired date and time through a time filter if-condition.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      Josh,


      thank you for the advice. In my case that would imply an additional property in my strategies that just serves that purpose of backtesting.
      ... and I like small and concise code...

      Regards

      Comment


        #4
        Unfortunately that simply is not the usage model for that property.
        Josh P.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by argusthome, 03-08-2026, 10:06 AM
        0 responses
        69 views
        0 likes
        Last Post argusthome  
        Started by NabilKhattabi, 03-06-2026, 11:18 AM
        0 responses
        42 views
        0 likes
        Last Post NabilKhattabi  
        Started by Deep42, 03-06-2026, 12:28 AM
        0 responses
        24 views
        0 likes
        Last Post Deep42
        by Deep42
         
        Started by TheRealMorford, 03-05-2026, 06:15 PM
        0 responses
        27 views
        0 likes
        Last Post TheRealMorford  
        Started by Mindset, 02-28-2026, 06:16 AM
        0 responses
        54 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Working...
        X