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 Mindset, 04-21-2026, 06:46 AM
        0 responses
        63 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by M4ndoo, 04-20-2026, 05:21 PM
        0 responses
        90 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by M4ndoo, 04-19-2026, 05:54 PM
        0 responses
        47 views
        0 likes
        Last Post M4ndoo
        by M4ndoo
         
        Started by cmoran13, 04-16-2026, 01:02 PM
        0 responses
        105 views
        0 likes
        Last Post cmoran13  
        Started by PaulMohn, 04-10-2026, 11:11 AM
        0 responses
        63 views
        0 likes
        Last Post PaulMohn  
        Working...
        X