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 helpwanted, Today, 03:06 AM
    1 response
    10 views
    0 likes
    Last Post sarafuenonly123  
    Started by Brevo, Today, 01:45 AM
    0 responses
    8 views
    0 likes
    Last Post Brevo
    by Brevo
     
    Started by aussugardefender, Today, 01:07 AM
    0 responses
    5 views
    0 likes
    Last Post aussugardefender  
    Started by pvincent, 06-23-2022, 12:53 PM
    14 responses
    242 views
    0 likes
    Last Post Nyman
    by Nyman
     
    Started by TraderG23, 12-08-2023, 07:56 AM
    9 responses
    386 views
    1 like
    Last Post Gavini
    by Gavini
     
    Working...
    X