• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NinjaTrader.Cbi.InstrumentList.GetInstruments()...

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

    NinjaTrader.Cbi.InstrumentList.GetInstruments()...

    In my indicator, I'm trying to populate an enum with an InstrumentList. Could you please point me to an example of how to access this?

    Code:
    NinjaTrader.Cbi.InstrumentList.GetInstruments("Futures");

    #2
    Hello,

    Thank you for the question.

    It appears the method you are using would not be the correct method to get a list, it seems instead you would need to use the underlying collection.

    You would either need to loop through the instrument list collection to find the list first, or use linq to find a match in the instrument list. I have provided an example using linq to cut down the size:


    Code:
    InstrumentList myList = NinjaTrader.Cbi.InstrumentList.InstrumentLists.First(list => list.Name == "FOREX");
    if (myList == null) return;
    foreach (Instrument instrument in myList.Instruments)
    {
    	Print(instrument.FullName);
    }

    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment


      #3
      Thank you, got it.

      Comment


        #4
        Hello,

        Glad you were able to get it, the sample will be posted here for anyone that needs a script example as well.

        I look forward to being of further assistance.
        Attached Files
        Last edited by NinjaTrader_Jesse; 05-24-2016, 08:09 AM. Reason: adjusted content
        JesseNinjaTrader Customer Service

        Comment


          #5
          Yes it was my mistake, I had an enum called InstrumentList and it was throwing the error.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by sergey_z, Today, 05:44 AM
          0 responses
          2 views
          0 likes
          Last Post sergey_z  
          Started by NinjaCustomer, Today, 12:29 AM
          1 response
          10 views
          0 likes
          Last Post NinjaTrader_ChrisSch  
          Started by ronaldgreene828, Yesterday, 07:50 PM
          1 response
          15 views
          0 likes
          Last Post NinjaTrader_EricB  
          Started by nailz420, 07-17-2019, 08:38 AM
          2 responses
          14 views
          0 likes
          Last Post nailz420  
          Started by bouncetherubble, Yesterday, 06:56 PM
          0 responses
          9 views
          0 likes
          Last Post bouncetherubble  
          Working...
          X