Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by GussJ, 03-04-2020, 03:11 PM
    11 responses
    3,222 views
    0 likes
    Last Post xiinteractive  
    Started by andrewtrades, Today, 04:57 PM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by chbruno, Today, 04:10 PM
    0 responses
    7 views
    0 likes
    Last Post chbruno
    by chbruno
     
    Started by josh18955, 03-25-2023, 11:16 AM
    6 responses
    438 views
    0 likes
    Last Post Delerium  
    Started by FAQtrader, Today, 03:35 PM
    0 responses
    10 views
    0 likes
    Last Post FAQtrader  
    Working...
    X