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

Copy Instrument from List A to List B

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

    Copy Instrument from List A to List B

    hello,
    some small question today.

    How can i copy with a C# script an instrument from instrument list "A" to instrument list "B" when a condition/indicator is TRUE, for example ?



    thank you.

    Stefan

    #2
    Hello galieo,

    Thank you for your inquiry and welcome to the NinjaTrader Support Forum!

    To clarify, are you wishing to dynamic add instruments to an instrument list through code? Unfortunately, you would not be able to do this.

    However, we do have undocumented code here that will allow you to loop through an instrument list:
    Code:
    // ensure to change "Default" to the name of the instrument list you are trying to access
    NinjaTrader.Cbi.InstrumentList listOfInstruments = NinjaTrader.Cbi.InstrumentList.GetObject("Default");
    
    foreach (Instrument instrument in listOfInstruments.Instruments)
    {
         // do something
    }
    Please, let us know if we may be of further assistance.
    Zachary G.NinjaTrader Customer Service

    Comment


      #3
      That would be a useful command for scripting. As it is not possible, just use the output window with a print command when your condition is true. After processing your instrument list copy the output window contents and paste into File | Utilities | Import Stock Symbol List.
      Print (Instrument.FullName + ",")

      Comment


        #4
        Hello AbcRocks,

        Thank you for your reply and welcome to the NinjaTrader Support Forum!

        I just wanted to clarify that utilizing Import Stock Symbol List will not accomplish what galieo has asked.

        This utility allows one to import a list of stock symbols for adding instruments to the Instrument Manager in bulk.

        These instruments will already exist in the Instrument Manager.

        For more information about using this utility, please take a look at this link in the NinjaTrader help guide: http://ninjatrader.com/support/helpG...stock_symb.htm
        Zachary G.NinjaTrader Customer Service

        Comment


          #5
          Hello,
          I should have been more specific:
          When importing the list of stocks using the import utility, specify which instrument list you wish the list to go into. You may also specify a new list if desired. The list will then be imported into your desired instrument list.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by michi08, 10-05-2018, 09:31 AM
          2 responses
          737 views
          0 likes
          Last Post Denver_Wayne  
          Started by sightcareclickhere, Today, 01:55 PM
          0 responses
          1 view
          0 likes
          Last Post sightcareclickhere  
          Started by Mindset, 05-06-2023, 09:03 PM
          9 responses
          258 views
          0 likes
          Last Post ender_wiggum  
          Started by Mizzouman1, Today, 07:35 AM
          4 responses
          18 views
          0 likes
          Last Post Mizzouman1  
          Started by philmg, Today, 01:17 PM
          1 response
          8 views
          0 likes
          Last Post NinjaTrader_ChristopherJ  
          Working...
          X