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

Performance Question - multiple timeframes, adding to BarsArray[]

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

    Performance Question - multiple timeframes, adding to BarsArray[]

    I'm working on multiple timeframe strategy. I'm currently only using two sets of Bars, but I'm tinkering with another strategy that could use more - perhaps as many as ten different timeframes. That got me to wondering:

    (1) How "expensive", computationally, is it to use multiple sets of Bars in a strategy? Is there a practical limit? Is it more of a memory issue, or a CPU/horsepower issue? Assume that my strategy won't be executing seconds-long scalping trades, but minutes-to-hours-long intraday swing trades.

    (2) Is there any way to set, directly in the strategy's C# code, the style (tick vs minutes) and timeframe size of the BarsArray[0] "default" bars? Or will this set of bars always and only be set via the GUI interface? I'm comfortable working in computer code, so I'd actually rather set all of my strategy's parameters directly in C#, rather than a combination of C# and the StrategyAnalyzer backtest panel.

    (3) I asked question (2) because I thought that, if I didn't have coding control over BarsArray[0], and just ignored it in my strategy, that it would be "wasteful" of resources somehow. I suppose this is also just a different way of asking question (1) - "how expensive is an additional set of bars?" Is this flawed thinking?

    #2
    Hi pbailey19,

    Thanks for your post.

    1) Each additional data series added will add the memory (for each point of data on each bar of the historical data and collected real time data) and will also cause OnBarUpdate to process once for each bar for each data series.

    Lets say you have added 4 data series of different instruments with a 1 minute time frame on each. This would mean that every minute OnBarUpdate would run 4 times at the end of the minute, once for each data series (changing the bars in progress). This means that the CPU usage will increase for each data series added.

    2) It is not possible to programmatically change the instrument or interval of the primary data series.

    This will always be the instrument and interval of primary data series of the chart created by the GUI.

    It is possible to decide the instrument and interval of added series.

    3) I not quite sure what you mean here. How are multiple data series affected by wanting to change the primary data series interval? You could make a script that doesn't use the primary series for processing and only processes on the added series if desired.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Thanks for the replay. Let me see if I can clear up Question (3).

      Let's say that I'm creating a multiple timeframe strategy, and I want to set all of my data series in the C# code. So let's say I'm using four data series: 3500-Tick, 6-minute, 20-minute, and 60-minute. But when I run a StrategyAnalyzer and select my strategy, it comes up with a default setting of 1-minute.

      That means that even though my strategy is only concerned with the four data series I mentioned, I'll also have another data series, BarsArray[0], created, with 1-minute bars ... even though I'm not using them.

      So that got me to wondering ... how much of a "penalty" am I paying for ignoring/wasting the BarsArray[0] data series?

      Comment


        #4
        Hi pbailey19,

        I understand, thanks for clarifying.

        Yes that would have a data series that isn't being used. This would still take up memory, but as long as you are ignoring any processing for that BarsInProgress then it won't take up much processing power if any.
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Enum and hosting indicators

          I don't know if this addresses the performance issue, but in an ebook entitled "NinjaScript Programmers Launch Pad", it describes the use of enum to describe different states. It also shows how to access data elements from the onBarUpdate() method of a hosting Indicator or Strategy.

          I have had some difficulties trying to use different time frames in a strategy so now I have been trying to use hosting indicators to host other indicators. I wonder if you have tried this?

          Ken

          Comment


            #6
            Hi Ken,

            Thanks for your note.

            I would be happy to assist you with multiple time frames in a NinjaScript strategy.

            However, I want to mention that when it comes to calling an indicator that has multiple time frames things can become very confusing very quickly. I wouldn't recommend this unless you are an advanced NinjaScript programmer.
            Chelsea B.NinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Stanfillirenfro, Yesterday, 09:19 AM
            7 responses
            51 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by TraderCro, 04-12-2024, 11:36 AM
            4 responses
            69 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by Mindset, Yesterday, 02:04 AM
            1 response
            15 views
            0 likes
            Last Post Mindset
            by Mindset
             
            Started by agclub, 04-21-2024, 08:57 PM
            4 responses
            18 views
            0 likes
            Last Post NinjaTrader_Gaby  
            Started by Irukandji, Today, 04:58 AM
            0 responses
            6 views
            0 likes
            Last Post Irukandji  
            Working...
            X