Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

How to control the number of bars to pre-calculate when a strategy starts?

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

    How to control the number of bars to pre-calculate when a strategy starts?

    In the document

    "An extremely common scenario is starting a NinjaScript strategy in the middle of a trading session, such as one hour after the session has begun.. The NinjaScript strategy is run on each historical bar for the 1st hour of the session (it will actually run on all historical data loaded in a chart) to determine the current position state it would be in if it had been running live since the start of the session. This position state then becomes the Strategy Position for your strategy. Let us assume that during the historical hour your strategy would have entered a LONG 1 position and the position is still open. This would mean the Strategy Position is LONG 1 and since this trade was not actually executed on an account your Account Position is FLAT."

    As far as I understand, it will pre-calculate the program state using the bars since session began. Is there any way to control the number of bars to use?

    Another question: I tried to start a strategy and monitor the OnBarUpdate event, but it does not behave like specified in the document. It loads much more bars (two weeks) than it should (since session began).

    Thanks,
    Jason

    #2
    Hi Jason, the strategy will take all the historical data loaded on your chart.

    If you start it from the 'Strategies' tab, it would load whatever is set in your chart default lookback - Tools > Options > Data.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    559 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    324 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    101 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    546 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    547 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X