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

loading instruments list INSIDE script

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

    loading instruments list INSIDE script

    Hi,

    I would like to load a whole instruments list INSIDE my script, rather than hardcoding adding hundreds or thousands of stocks line by line in my code. I need to use the data from all of them at once to construct my strategy. To be clear, I am not just trying to run a single-instrument strategy on a whole list of instruments (this I know how to do).

    Do you have some sample code that can demonstrate this?
    Thanks

    #2
    Protis, there would be unfortunately nothing supported for loading a complete instrument list in, however we have this on our list of feedback collected. I will make sure to add a vote on your behalf in to this item as well, for now an Add() line in Initializer() for your instruments desired would be needed as shown in our SampleMultiInstrument strategy shipped with NT.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Thanks Bertrand.

      Perhaps if I loaded a file that contained the ticker names, I could code a loop which would call Add() on each ticker? This way I wouldn't need to hardcode a massive list of Add() calls..

      Is this possible? And if so, is there any sample code available that might help me?

      Thanks!

      Comment


        #4
        Protis, you could be looking into this snippet here, although this is not a technique we officially could support -

        NinjaTrader.Cbi.InstrumentList list1 = NinjaTrader.Cbi.InstrumentList.GetObject("your instrument list string");

        foreach (Instrument i in list1.Instruments)
        {
        Add(i.FullName, PeriodType.Minute, 1); // add your type and period here
        }
        BertrandNinjaTrader Customer Service

        Comment


          #5
          thank you very much!!

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by r68cervera, Today, 05:29 AM
          0 responses
          2 views
          0 likes
          Last Post r68cervera  
          Started by geddyisodin, Today, 05:20 AM
          0 responses
          3 views
          0 likes
          Last Post geddyisodin  
          Started by JonesJoker, 04-22-2024, 12:23 PM
          6 responses
          35 views
          0 likes
          Last Post JonesJoker  
          Started by GussJ, 03-04-2020, 03:11 PM
          12 responses
          3,239 views
          0 likes
          Last Post Leafcutter  
          Started by AveryFlynn, Today, 04:57 AM
          0 responses
          6 views
          0 likes
          Last Post AveryFlynn  
          Working...
          X