Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Adding all stocks in a script

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

    Adding all stocks in a script

    Hello,

    I'm trying to add all stocks of SP500 and NQ in an indicator for Ninjatrader8 .

    I found this code but it's for NT7 and doesn't work for NT8.
    Code:
    NinjaTrader.Cbi.InstrumentList list1 = NinjaTrader.Cbi.InstrumentList.GetObject("FOREX");
    foreach (Instrument i in list1.Instruments) {
    Add(i.FullName, PeriodType.Minute, 5);
    }
    Thanks

    #2
    Hello lju45,

    The only correct way to add the data would be to type in all instruments as individual AddDataSeries statements. At this time AddDataSeries is not intended to be used dynamically and may fail to load data by using runtime variables instead of hard coding the instruments into the script.

    This is also an area where you would need to ahead of time ensure that you can see live data for all instruments using the market analyzer. Depending on your connection you may not be able to subscribe all instruments at once and you may instead need to make a shorter list of stocks you want to trade.



    •Arguments supplied to AddDataSeries() should be hardcoded and NOT dependent on run-time variables which cannot be reliably obtained during State.Configure (e.g., Instrument, Bars, or user input). Attempting to add a data series dynamically is NOT guaranteed and therefore should be avoided. Trying to load bars dynamically may result in an error similar to: Unable to load bars series. Your NinjaScript may be trying to use an additional data series dynamically in an unsupported manner.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    633 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    364 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    105 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    567 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    568 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X