Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Best method to fetch prior data of another interval

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

    Best method to fetch prior data of another interval

    I have an indicator that works with ticks or one minutes bars interval and that from the start (first bars) needs to fetch the prior 60*100 minutes (i.e 100 bars of a 60minute interval) as BarsArray[1].
    What's the best approach to achieve this?
    Thank you.
    Gio

    #2
    Hello giogio1,

    Thank you for your post.

    What data specifically are you trying to obtain? For example, if you want Price data like the Close price of the added series you can use the Closes collection.



    Closes[1][0] is the Close price of the currently processing bar (0 bars ago) in the secondary series (BarsArray[1]).
    Closes[1][100] is the Close price 100 bars ago from the secondary series.

    Please let me know if this doesn't guide you in the right direction.

    Comment


      #3
      Thank you Gaby, I meant something different, sorry for not being clear.
      I have a 100 ticks chart and I am at the begiinning of the chart,, say bar 10 which I get with Closes[0][10]
      From that point I need to load another BarsArray and get the previous 100 bars of 60 minutes.
      If I code Closes[1][100] I would get out of boundary array error, because it never loaded 100 bars back, unless I load many days back of tick data and I also wouldn't get, I think , the necessary flexibility. Correct if I am wrong.
      In the past with NT7 I could use the iBar class but it is undocumented and I cannot convert it NT8 the same way.
      Can you give me a lead?
      Best
      Gio

      Comment


        #4
        Hello giogio1,

        Thank you for your response.

        Correct, if you wanted to obtain the 100th bar from the secondary series while also accessing the 10th bar from the primary series, you would need to use that both of those bars have already been processed by the strategy. You would also need to make sure the chart you are applying to has over 100 bars worth of data in order for the strategy to process that data. When using AddDataSeries, there is no workaround for this.

        You could use a BarsRequest to simply request the amount of barsBack worth of data you want for another series, however note that the data requested is not synchronized with an indicator's primary data series. You will need to implement your own BarsUpdateEvent logic. You would also not be able to use this data as input for an indicator.

        All data also must requested by barIndex, not by barsAgo values using methods like GetClose(). So if you wanted to obtain the value 100 bars ago, you would need to know the barIndex of that bar.



        Last edited by NinjaTrader_Gaby; 11-15-2024, 06:51 AM.

        Comment


          #5
          Thank you very much Gaby! I'll work calmly on the Asynch'd BarsRequest solution.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          656 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          371 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          109 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          574 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          579 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X