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 CaptainJack, 05-29-2026, 05:09 AM
    0 responses
    263 views
    0 likes
    Last Post CaptainJack  
    Started by CaptainJack, 05-29-2026, 12:02 AM
    0 responses
    168 views
    0 likes
    Last Post CaptainJack  
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    170 views
    1 like
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    257 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    209 views
    0 likes
    Last Post CarlTrading  
    Working...
    X