Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Instrument List

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

    Instrument List

    Is there any way to get the instrument list for the current instrument from code?
    Basically I need to do different action depending on which list the current instrument is in.

    Thanks

    #2
    Hello wookey, and thank you for your question.

    There is no direct way to map instruments to instrument lists.

    Going the other way - instrument list to instrument - while this is not documented, and we can only offer limited support, you may loop through instrument lists using this code :

    Code:
    [FONT=Courier New]string instrumentListName = "FOREX";
    NinjaTrader.Cbi.InstrumentList list1 = NinjaTrader.Cbi.InstrumentList.GetObject(instrumentListName);
    
    foreach (Instrument i in list1.Instruments)
    {
        Print("My name is " + i.FullName);
    }
    
    [/FONT]
    You could, then, store a list of instrument list names in your code, and then loop through them to see if a given instrument is on a list. This will in turn allow you to map instruments back to instrument lists, which should resolve your query. That code may look like this :

    Code:
    [FONT=Courier New]private string[] instrumentLists = {"FOREX"};
    private static string listFromInstrument(Instrument instrument)
    {
        foreach(string instrumentList in instrumentLists)
        {
            NinjaTrader.Cbi.InstrumentList list1 = NinjaTrader.Cbi.InstrumentList.GetObject(instrumentList);
    
            foreach (Instrument i in list1.Instruments)
            {
                if (i.FullName == instrument.FullName)
                {
                    return instrumentList;
                }
            }
        }
        return "Default";
    }
    [/FONT]
    Please let us know if there are any other ways we can help.
    Jessica P.NinjaTrader Customer Service

    Comment


      #3
      This solution works. Thank you!

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      558 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      324 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      101 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      545 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      547 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X