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

Programmatically Access instrument list

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

    Programmatically Access instrument list

    Hi

    How does one programmatically Access an instrument list?

    I need a strategy to load a list of instruments and instead of hardcoding or reading from a file I would like to add from an instrument list.

    Thanks

    Mike

    #2
    Hi Mike, unfortunately the instruments lists could not be accessed programmatically.
    BertrandNinjaTrader Customer Service

    Comment


      #3
      Have been doing a little snooping around using the object browser in Visual Studio and have figured it out.

      NinjaTrader.Cbi.InstrumentList list = NinjaTrader.Cbi.InstrumentList.GetObject("FX");

      foreach (Instrument i in list.Instruments) {
      Add(i.FullName, PeriodType.Minute, 60);
      }

      Cheers

      Mike

      Comment


        #4
        Thanks for this example, upshon. The ForEach loop generates an "Object Reference not set to instance of an object" error... What's missing?

        I did add a using declaration for Ninjatrader.Cbi.

        Thanks.
        Last edited by Ricam; 03-20-2012, 01:45 PM.

        Comment


          #5
          NinjaTrader.Cbi.InstrumentList list = NinjaTrader.Cbi.InstrumentList.GetObject("FX");

          FX is the name of the custom list I created, I suspect you need to change this with a let you have.

          Comment


            #6
            Would you be kind enough to provide additional information on how you did this, I unfortunately am at a dead end. How was list created, where is it located, does a reference need to be added to be able to find it, etc. Thanks

            Comment


              #7
              Go to Tools Menu then select "Instrument Manager"

              There is a drop down called "Instrument Lists", there you can create new lists or manage the contents of existing lists.

              Use the name of the "Instrument Lists" as the parameter in

              NinjaTrader.Cbi.InstrumentList list = NinjaTrader.Cbi.InstrumentList.GetObject("FX");

              Comment


                #8
                Thanks upshon, that did it.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by Aviram Y, Today, 05:29 AM
                0 responses
                1 view
                0 likes
                Last Post Aviram Y  
                Started by quantismo, 04-17-2024, 05:13 PM
                3 responses
                25 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by ScottWalsh, 04-16-2024, 04:29 PM
                7 responses
                34 views
                0 likes
                Last Post NinjaTrader_Gaby  
                Started by cls71, Today, 04:45 AM
                0 responses
                6 views
                0 likes
                Last Post cls71
                by cls71
                 
                Started by mjairg, 07-20-2023, 11:57 PM
                3 responses
                216 views
                1 like
                Last Post PaulMohn  
                Working...
                X