Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

BarsRequired - how to add tick and volume bars to the same indicator?

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

    BarsRequired - how to add tick and volume bars to the same indicator?

    I'm looking to run an indicator with 1-tick bars as the primary bar series (i.e., a 1-tick chart) and 1000-volume bars as the secondary series.

    I haven't been able to figure out how to get around the 'index out of range' error. What should I set BarsRequired in Initialize()?

    Or given the following, what should x== and y==?
    if (CurrentBars[0] <= x || CurrentBars[1] < y)
    return;

    #2
    Hello bluelou,

    Thank you for your response.

    You would want to check CurrentBars[barsInProgressIndex] against the largest value you use for barsAgo.

    Comment


      #3
      Is barsInProgressIndex available to the Indicator class? I only see it for Strategies in the Help files. This is for an Indicator.

      Comment


        #4
        Hello bluelou,

        Thank you for your response.

        Yes, please visit the following link for information on multiple bar series and instruments in your code: http://www.ninjatrader.com/support/h...nstruments.htm

        Comment


          #5
          nvm. I'll take a closer look. Don't know why BIP index threw me off, I use it everyday.

          Comment


            #6
            Originally posted by NinjaTrader_PatrickH View Post
            Hello bluelou,

            Thank you for your response.

            You would want to check CurrentBars[barsInProgressIndex] against the largest value you use for barsAgo.
            Patrick,
            I'm still not sure of exactly what object I'm supposed to check against.

            1) I have 2 data series, the primary series is 1-tick bars and the secondary series is 1000-volume bars.

            2) For the secondary series my largest value for barsAgo is 30. For the primary series the largest value is unknown. I use all of the ticks in between each 1000-volume bar and then I dump them on each new secondary bar.

            3) If I use time-based bars only then I can use a statement like this. (This is for 1-second primary and 5 minute secondary bars.) But, this isn't working for a mix of tick and volume data series
            if (CurrentBars[0] < 1200 || CurrentBars[1] < 1)

            Comment


              #7
              Ah, maybe it was too obvious. I think this is working but need to test the values. I just put in a large value for CurrentBars[0] since the quantity is unknown and I know the secondary value is always < 30. I'll post again if I'm still having problems. Thx.

              if (CurrentBars[0] < 100000 || CurrentBars[1] < 30)
              return;

              Comment


                #8
                Hello bluelou,

                Thank you for your post.

                I would think if (CurrentBars[0] < 30 || CurrentBars[1] < 30)return; would be sufficient. Unless you look further back on the current bar than 30.

                Comment


                  #9
                  Patrick, you're right, thx for that. With a better understanding of the logic now I have no idea why my original version worked on time-based bars. But, that's something to figure out another day. Thx again.

                  //Old version - which actually worked for whatever reason
                  if (CurrentBars[0] < 1200 || CurrentBars[1] < 1)

                  Comment


                    #10
                    Patrick,
                    Unfortunately, the problem is persisting for different data series.

                    For primary = 1 tick and secondary = 1000 volume the following statement works. Again, in this case the number of primary bars required is unknown and the number of secondary bars required is >30.

                    if (CurrentBars[0] <= 30 || CurrentBars[1] <= 30)
                    return;

                    If I use the exact same code for primary = 1 second and secondary = 5 minutes I get an index out of range error. What is problem with using the code above and time-based bars?

                    Comment


                      #11
                      Hello bluelou,

                      Thank you for your response.

                      You would need to know how many bars the code is going to look back, if we only have 30 bars so far and you try to go back 31 we would get an error. So in your code, what would be the farthest back it would look? Can you provide you code?

                      Comment


                        #12
                        Patrick,
                        CurrentBars[1] <= 30. In this particular instance I'm only 20 bars ago but I've kept to <= 30 as a default.

                        This should be pretty straightforward with time based bars where primary = 1 second and secondary = 5 minute bars.

                        I've tried a few combinations, like setting both currentbars = 50/100/100. I still get index out of range even though barsAgo is really only 20 on the slower period, secondary series.

                        Moreover, with time based bars we know 1 5-minute bars = 300 1-second bars. For instance, I also tried CurrentBars[0] = 9000, CurrentBars[1] = 30 but this resulted in index out of range. But, there shouldn't be any mystery here. The code is proprietary so there's nothing I can send, unfortunately.
                        Last edited by bluelou; 11-12-2014, 02:05 PM.

                        Comment


                          #13
                          Hello bluelou,

                          Thank you for your response.

                          Unfortunately, without knowing what the code is doing I cannot say what would be causing this.
                          You may wish to look into debugging the code: http://www.ninjatrader.com/support/f...ead.php?t=3418

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by kujista, Today, 05:44 AM
                          0 responses
                          6 views
                          0 likes
                          Last Post kujista
                          by kujista
                           
                          Started by ZenCortexCLICK, Today, 04:58 AM
                          0 responses
                          9 views
                          0 likes
                          Last Post ZenCortexCLICK  
                          Started by sidlercom80, 10-28-2023, 08:49 AM
                          172 responses
                          2,281 views
                          0 likes
                          Last Post sidlercom80  
                          Started by Irukandji, Yesterday, 02:53 AM
                          2 responses
                          18 views
                          0 likes
                          Last Post Irukandji  
                          Started by adeelshahzad, Today, 03:54 AM
                          0 responses
                          11 views
                          0 likes
                          Last Post adeelshahzad  
                          Working...
                          X