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

Adding 1 second, 60 second, 1 minute, or 450 minute bar resource question

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

    Adding 1 second, 60 second, 1 minute, or 450 minute bar resource question

    Hello,

    Does the BarsPeriodType or the period values of those types drastically affect the system resources or optimization of a strategy?


    For instance using the following examples:

    Using AddDataSeries(string instrumentName, BarsPeriod barsPeriod, string tradingHoursName)


    1.) AddDataSeries("ES 03-21", new BarsPeriod { BarsPeriodType = BarsPeriodType.Second, Value = 60 }, "CME US Index Futures RTH"); // 60 second bars

    2.) AddDataSeries("ES 03-21", new BarsPeriod { BarsPeriodType = BarsPeriodType.Second, Value = 1 }, "CME US Index Futures RTH"); // 1 second bars

    3.) AddDataSeries("ES 03-21", new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 1 }, "CME US Index Futures RTH"); // 1 minute bars

    4.) AddDataSeries("ES 03-21", new BarsPeriod { BarsPeriodType = BarsPeriodType.Minute, Value = 450 }, "930am-500pm"); // 450 minute bars with a custom intraday trading hours template


    or using the simpler

    5.) AddDataSeries("ES 03-21", Data.BarsPeriodType.Second, 1); // 1 second bars




    Would any of these create a substantial difference in allocated system resources when they load or when data from them is called?


    With all the values from added data series being indexed by NT while a strategy is running, having the fewest stored values seems ideal. So if I only need the opening value of bar that opens at 9:30 am, and this value is only called once during during the life of the strategy during the first iteration of OnBarUpdate at 9:30:01 am, creating a bar that will only add one value to that index for the life of the strategy seems to be the best solution. Opposed to using a 1 minute or 1 second bar and period type that would store many values while a strategy is running for many hours.

    Or does this not really impact the performance of a strategy very much?



    And when might the overload with barsToLoad be used? Is this primarily for adding data series in indicators?
    Or will loading bars here satisfy the value of BarsRequiredToTrade value by loading historical bars?




    Thank you for any information


    #2
    Hello 9817_dynamic,

    The amount of resources it takes would depend on how many bars the series has when it needs to load. There is otherwise not any difference between the calls.

    The overload with BarsToLoad would be used if you wanted to load a specific number of bars.

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      I appreciate your reply,

      So just to clarify, if only 1 or 2 historical bars are required for a strategy, adding a 1 second ES data series does not require more system resources while the strategy is running than adding a 1 minute or 1 hour ES series to the strategy?

      And if BarsToLoad is not used is the default number of bars loaded in the added series the same number of bars as the chart that the strategy is running on? Or is it the same number of bars to satisfy the time frame of the chart? I see if I start a strategy in the Control Center without a chart a prompt for Days To Load is required. So is it always based on a number of days to load?


      Thank you again for any info

      Comment


        #4
        Hello 9817_dynamic,

        So just to clarify, if only 1 or 2 historical bars are required for a strategy, adding a 1 second ES data series does not require more system resources while the strategy is running than adding a 1 minute or 1 hour ES series to the strategy?
        The historical bars will need to be processed by the bars type. Initially the more granular series will call the bars type more to build the bars. The end result will be the 2 bars and then would be available to the script in the series. In terms of resources that is just 2 processed bars however using a more granular series will increase load time to build those bars.
        While in realtime the added series will cause the OnBarUpdate override to be called for that series as well. If you don't add logic to separate your logic based on the bars in progress that may also add additional performance hits. It would otherwise just work the bars type logic to build the bars in realtime and eventually become 3 bars etc.


        And if BarsToLoad is not used is the default number of bars loaded in the added series the same number of bars as the chart that the strategy is running on? Or is it the same number of bars to satisfy the time frame of the chart? I see if I start a strategy in the Control Center without a chart a prompt for Days To Load is required. So is it always based on a number of days to load?
        If BarsToLoad is not used it would use the settings from where the script is applied based on its primary series. Strategies can have different settings depending on if you load from the control center or a chart. A chart has a specific timeframe in view up to the current time. The control center makes no assumption of a view starting point and lets you set the amount of data needed by your script. That assumes the strategy is going to be actively working in realtime and not necessarily doing a backtest on a chart where you want to view those results.



        I look forward to being of further assistance.

        JesseNinjaTrader Customer Service

        Comment


          #5
          Thank you for the info!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by helpwanted, Today, 03:06 AM
          1 response
          16 views
          0 likes
          Last Post sarafuenonly123  
          Started by Brevo, Today, 01:45 AM
          0 responses
          11 views
          0 likes
          Last Post Brevo
          by Brevo
           
          Started by aussugardefender, Today, 01:07 AM
          0 responses
          6 views
          0 likes
          Last Post aussugardefender  
          Started by pvincent, 06-23-2022, 12:53 PM
          14 responses
          244 views
          0 likes
          Last Post Nyman
          by Nyman
           
          Started by TraderG23, 12-08-2023, 07:56 AM
          9 responses
          387 views
          1 like
          Last Post Gavini
          by Gavini
           
          Working...
          X