Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Data Initialization and MaximumBarsLookBack

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

    Data Initialization and MaximumBarsLookBack

    I have a large amount of historical data, and I would like the access this data during a backtest (for a single instument).

    Suppose I run a backtest in the Strategy Analyzer, with a starting time of 1 January 2012, and an ending time of 1 February 2012. I enter these dates into the Strategy Analyzer window.

    On the first bar of the backtest (first bar of 1 January 2012), I want to look back at prices from the year 2011. I do it this way:

    Code:
     
    DateTime CurrentTime = Time[0]; 
    DateTime TargetTime = CurrentTime.Subtract(new TimeSpan (LookbackDays,LookbackHours,0,0)); 
    TargBar = Bars.GetBar(TargetTime); 
    LookbackBars = CurrentBar - TargBar;
    where CurrentTime is 1 January 2012, and I want to know Close[LookbackBars].

    The problem is that NT yields LookbackBars = CurrentBar until the backtest has ran for a longer than my lookback window: NT is not loading more bars than it think it needs to.

    How can I load more bars, and yet start the backtest on 1 January 2012?

    Will MaximumBarsLookBack = Infinity work? Can I Add() more bars?

    Thanks!

    #2
    Originally posted by Serac View Post
    I have a large amount of historical data, and I would like the access this data during a backtest (for a single instument).

    Suppose I run a backtest in the Strategy Analyzer, with a starting time of 1 January 2012, and an ending time of 1 February 2012. I enter these dates into the Strategy Analyzer window.

    On the first bar of the backtest (first bar of 1 January 2012), I want to look back at prices from the year 2011. I do it this way:

    Code:
     
    DateTime CurrentTime = Time[0]; 
    DateTime TargetTime = CurrentTime.Subtract(new TimeSpan (LookbackDays,LookbackHours,0,0)); 
    TargBar = Bars.GetBar(TargetTime); 
    LookbackBars = CurrentBar - TargBar;
    where CurrentTime is 1 January 2012, and I want to know Close[LookbackBars].

    The problem is that NT yields LookbackBars = CurrentBar until the backtest has ran for a longer than my lookback window: NT is not loading more bars than it think it needs to.

    How can I load more bars, and yet start the backtest on 1 January 2012?

    Will MaximumBarsLookBack = Infinity work? Can I Add() more bars?

    Thanks!
    NT does not expose a supported programmatic way to specify the number of days to load into any of its tools. If you want to start your data from a specific date, then you have to manually load the data when you start your analysis. IOW, you must specify your data start date using the config GUI.

    Comment


      #3
      Hello,

      Unfortunately you will not be able to add data from a specific period. It will only use a range of data in which you have specified for the backtest.

      As a workaround, you can set the start/end date for the backtest within a range of data you need to use, and then program the strategy to not start until Jan 1 2012.
      MatthewNinjaTrader Product Management

      Comment


        #4
        Thanks for your fast responses.

        I was afraid this was the case.

        MaximumBarsLookBack is of no help, then?

        Comment


          #5
          Not currently - this just controls how many bars are used within the range that is loaded. Infinite starts at the first bar in the series.
          MatthewNinjaTrader Product Management

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          650 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          370 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          109 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          574 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          577 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X