Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Multi TimeFrames -- 2nd Secondary

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

    Multi TimeFrames -- 2nd Secondary

    I'm getting an error when trying to access secondary bars when using multi-timeframes. The primary chart is a 15-minute chart and I'm adding a 5-minute and 125-Tick chart in the Initialize function.

    In the OnBarUpdate function, I'm able to access data in the 5-minute chart, but unable to get data for the 125-tick chart.

    My understanding is the the BarsArray object is zero based with the first item being the primary bars.

    Below is the code snippet I'm using. I'm getting the error on the third Print statement.

    So my main question is why the second instrument(125-Tick), not being populated correctly. When I check the Length property of the BarsArrary object it's reporting 3.


    In my Initialize function I have the following

    See Attachment
    Attached Files

    #2
    dpennypacker, I don't think that is the issue. In your code snippet, I see the error is this:
    Code:
    Error on calling 'OnBarUpdate' method for indicator 'PriceActionPlus3X' on bar 0: You are accessing an index with a value that is invalid since its out of range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.
    That error is typically caused by trying to access data that doesn't actually exist. For example, on the very first bar the indicator sees, if you try to access High[1], the error will happen because there is only one bar to deal with.

    Would you mind posting the complete code so I can see what else is going on in the indicator?
    AustinNinjaTrader Customer Service

    Comment


      #3
      re: Multi TimeFrames -- 2nd Secondary

      NinjaScript is attached.

      Comment


        #4
        dpennypacker, unfortunately nothing was attached to the previous post. To attach a file, click the little paper clip above the response box, select the file you wish to attach, click upload, and then submit the reply.

        Oh and I forgot to say this in my first post, but welcome to the forums!
        AustinNinjaTrader Customer Service

        Comment


          #5
          re: Multi TimeFrames -- 2nd Secondary

          2nd attempt at the attachment.
          Attached Files

          Comment


            #6
            Hi there, I ran your script with some additional Print() statements scattered throughout your Print() statements and determined the issue lies within these codes:
            Code:
            Print(string.Format("k12: {0}, k22: {1}, k32: {2}", k12.K[0],k22.K[0],k32.K[0]));
            Print(string.Format("k13: {0}, k23: {1}, k33: {2}", k13.K[0],k23.K[0],k33.K[0]));
            After adding a simple bar check, the script runs fine. Please add this snippet after your BarsInProgress check:
            Code:
            if (CurrentBar < 5)
                return;
            Two bars wasn't enough and five works so I just left it at that.

            Please take a look at the screenshot for what I just said in picture format.
            Attached Files
            AustinNinjaTrader Customer Service

            Comment


              #7
              I guess I'll have to read up a little more on the CurrentBar.

              Thanks for looking at this.

              Comment


                #8
                This is the tip we have for making sure you have enough bars in the data series you are accessing, which is basically what you're dealing with here.
                AustinNinjaTrader Customer Service

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by funk10101, Today, 09:43 PM
                0 responses
                3 views
                0 likes
                Last Post funk10101  
                Started by pkefal, 04-11-2024, 07:39 AM
                11 responses
                36 views
                0 likes
                Last Post jeronymite  
                Started by bill2023, Yesterday, 08:51 AM
                8 responses
                44 views
                0 likes
                Last Post bill2023  
                Started by yertle, Today, 08:38 AM
                6 responses
                26 views
                0 likes
                Last Post ryjoga
                by ryjoga
                 
                Started by algospoke, Yesterday, 06:40 PM
                2 responses
                24 views
                0 likes
                Last Post algospoke  
                Working...
                X