Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Loading Data to Series from File

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

    Loading Data to Series from File

    Hello, i am storing data in a database then recalling it whenever chart is reloaded to provide history for the indicator. I wait till state is dataloaded then attempt to load the data into a custom series using bar timestamps. I keep getting an index out of range error no matter what i try, anything but zero in the barsAgo of the custom series will cause this issue. My workaround currently is to load to Dict at this stage and Match up at state,historical. whilst this works fine i feel i mught be missing something as it seems a little ugly. Any help as to why i cannot load straight to series at data loaded would be appreciated, the series.count equates to the number of bars, but it will not let me access it. As i say index error.
    Thanks


    #2
    We don't have enough information, I don't think, to tell you what you're doing incorrectly here. At State.DataLoaded the NinjaTrader series are initialized but CurrentBar is 0. You would not be able to index back yet. If you're trying to load all the way from the start of the chart to real-time into a Series<double> do it in State.Transition not State.DataLoaded as by then CurrentBar is > 0 and equal to the first realtime bar index so you could index back from 0..CurrentBar into your Series<double>.
    Bruce DeVault
    QuantKey Trading Vendor Services
    NinjaTrader Ecosystem Vendor - QuantKey

    Comment


      #3
      Ah awesome, thanks Bruce, from my reading of the documentation i thought all was supposed to be available at data loaded. I will swap to transition. That gets rid of the ugly work around I had and will make for much cleaner looking code.
      Cheers legend!

      Comment


        #4
        Hello cdsmart,

        Bruce is correct, Series<double> are built, and indexes updated, as OnBarUpdate() processes each bar.

        The help guide provides a small mention of this.
        "Note: In most cases, you will access the historical price series using a core data event handler such as OnBarUpdate()."



        However, the Bars object with the historical data can be accessed in State.DataLoaded with Bars.GetClose(), Bars.GetTime(), etc.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

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