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

BarsRequiredToTrade - Historical to live trading

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

    BarsRequiredToTrade - Historical to live trading

    My strategy uses a moving average with a period of 200. My understanding therefor is that the BarsRequiredToTrade must be set to 200 to ensure enough historical data is available to perform the calculations. For backtesting, this is not a problem. However, once this strategy trades live, I don't want to have to wait 200 bars before the strategy starts looking for opportunities to open a position. The strategy is used on a daily chart which means I would have to wait 200 trading days before it will even start to look to open any positions.
    Is there any way to provide the strategy with historical data to fill in this data gap so that the strategy has sufficient data to start using the OnBarUpdate() immediately for the Realtime State calculation when it is trading live?

    #2
    Originally posted by JulieV View Post
    My strategy uses a moving average with a period of 200. My understanding therefor is that the BarsRequiredToTrade must be set to 200 to ensure enough historical data is available to perform the calculations. For backtesting, this is not a problem. However, once this strategy trades live, I don't want to have to wait 200 bars before the strategy starts looking for opportunities to open a position. The strategy is used on a daily chart which means I would have to wait 200 trading days before it will even start to look to open any positions.
    Is there any way to provide the strategy with historical data to fill in this data gap so that the strategy has sufficient data to start using the OnBarUpdate() immediately for the Realtime State calculation when it is trading live?
    You already gave the answer to your own problem.

    When creating the new chart that you add the strategy to, setup your "Days to Load" to be at least 200.

    The chart will load 200 days worth of historical bars, which your strategy will process as directed, just like it
    does in backtest.
    Attached Files

    Comment


      #3
      Hello JulieV,

      Thanks for your post.

      To elaborate on bltdavid's response, BarsRequiredToTrade is a setting that tells the strategy to wait until it has processed a certain number of bars before it is allowed to take trades. This counts historical bars and real time bars, so increasing your DaysToLoad or BarsToLoad will load more bars for the strategy to begin taking trades when it is processing historical data.

      Let us know if you have any additional questions.
      JimNinjaTrader Customer Service

      Comment


        #4
        Hi bltdavid
        Thanks for the attached file. I didn't realise the data series could be edited in this way.

        Comment


          #5
          Originally posted by NinjaTrader_Jim View Post
          Hello JulieV,

          Thanks for your post.

          To elaborate on bltdavid's response, BarsRequiredToTrade is a setting that tells the strategy to wait until it has processed a certain number of bars before it is allowed to take trades. This counts historical bars and real time bars, so increasing your DaysToLoad or BarsToLoad will load more bars for the strategy to begin taking trades when it is processing historical data.

          Let us know if you have any additional questions.
          Hi Jim
          Thanks for the explanation behind how BarsRequiredToTrade is calculated. I have gone into the data series of the instrument I am looking at and it's default setting is Days To Load = 365.
          Just to make sure I am understanding everything correctly here. Because the data series already loads in 365 days worth of data, the strategy will automatically have enough data available to start looking for trading opportunities immediately because the BarsRequiredToTrade is set to 200 which is less than what is already available?

          Comment


            #6
            Hello JulieV,

            To avoid confusion with Start Behaviors, I don't want to answer with a direct "yes."

            When the strategy starts it begins processing historical data to determine a virtual position which is later used by the strategy's Start Behavior when the strategy transitions to realtime data and begins taking live trades. I'll include some documented information on Start Behaviors and Strategy/Account Position to further clarify on how these work if further reference is needed.

            Having 365 DaysToLoad will ensure that the strategy has enough historical data to develop signals within the historical processing, so you will not be limited to taking trades when the strategy transitions to realtime. The data is already there and has been processed by the strategy.

            One final item that should be clear is that BarsRequiredToTrade limits when NinjaTrader allows orders to submit. It should not be confused with "Making sure you have enough data in the data series you are accessing" explained below.

            Making sure you have enough data in the data series you are accessing - https://ninjatrader.com/support/help...nough_bars.htm

            Reference for understanding Strategy Position vs. Account Position and Start Behaviors is linked below.

            Strategy vs. Account Position - https://ninjatrader.com/support/help..._account_p.htm

            Syncing Account Positions (Start Behaviors) - https://ninjatrader.com/support/help..._positions.htm

            Let me know if you have any other questions we can assist with.
            JimNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by geotrades1, Today, 10:02 AM
            1 response
            5 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by ender_wiggum, Today, 09:50 AM
            1 response
            5 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by rajendrasubedi2023, Today, 09:50 AM
            1 response
            12 views
            0 likes
            Last Post NinjaTrader_BrandonH  
            Started by bmartz, Today, 09:30 AM
            1 response
            10 views
            0 likes
            Last Post NinjaTrader_Erick  
            Started by geddyisodin, Today, 05:20 AM
            3 responses
            27 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Working...
            X