Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    BertrandNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by joselube001, Today, 12:17 PM
    2 responses
    10 views
    0 likes
    Last Post joselube001  
    Started by arangocj, Today, 12:37 PM
    1 response
    15 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by kevinenergy, Yesterday, 12:01 PM
    5 responses
    19 views
    0 likes
    Last Post NinjaTrader_Gaby  
    Started by Kraken29, Today, 12:32 PM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_Erick  
    Started by codeowl, 02-11-2019, 05:47 AM
    23 responses
    678 views
    0 likes
    Last Post stockbux  
    Working...
    X