Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Adding instrument programmatically

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

    Adding instrument programmatically

    Hi,
    is there a way to programmatically add (in the Initilize section of Indicator script) an instrument defined in Instrument manager but not included in any of the Instrument lists?
    For example ZM is defined in Instrument manager however I don't have ZM 07-13 in any of Instrument lists. When I add ZM 07-13 in Initialize, OnBarUpdate is never called.
    So how can work in Indicator script with instrument not included in any of the Instrument list?
    Thanks.

    #2
    Hello Harryx,

    Thank you for your post.

    How are you coding the Add() for the instrument?

    Is there an error message in your log tab of the Control Center?
    Cal H.NinjaTrader Customer Service

    Comment


      #3
      Instruction to add an instrument:
      Add("ZM 07-13", PeriodType.Day, 1);

      Log:
      The indicator 'aaTest1' has called the Add() method with an invalid instrument. Either 'ZM 07-13' does not exist in the Instrument Manager or the specified exchange has not been configured.

      Comment


        #4
        Harryx,

        You would want to use ZM 07-14 and not the 07-13 contract.
        Cal H.NinjaTrader Customer Service

        Comment


          #5
          No, I want to analyze historical data of ZM.

          Comment


            #6
            Harryx,

            You need to use the most current contract when adding an instrument to the script. When you run a back test, NinjaTrader will grab the correct information when looking back for that data.
            Cal H.NinjaTrader Customer Service

            Comment


              #7
              I don't want this behavior. My Merge policy is set to DoNotMerge as I want to evaluate individual contract months for the purpose of trading futures spreads .

              Comment


                #8
                Harryx,

                You would then need to load a chart and ensure the end dates for the chart do not go past the rollover date for the 07-13 contract

                - 4/17/213
                Cal H.NinjaTrader Customer Service

                Comment


                  #9
                  So back to my question again. How can I work (to add it in Initialize and evaluate in OnBarUpdate, no plotting on chart) with instrument programmatically in my script without loading each instrument manually (ZM 07-13, 07-12, 07-11,...)?

                  Comment


                    #10
                    Originally posted by harryx View Post
                    I don't want this behavior. My Merge policy is set to DoNotMerge as I want to evaluate individual contract months for the purpose of trading futures spreads .
                    Your code WILL obey the "Do not merge" directive, so your objection does not really hold merit. Price is price. If the prices have not been massaged (as in "Merge"), then, as always, WYSIWYG.

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Geovanny Suaza, 02-11-2026, 06:32 PM
                    0 responses
                    571 views
                    0 likes
                    Last Post Geovanny Suaza  
                    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
                    0 responses
                    330 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
                    549 views
                    1 like
                    Last Post Geovanny Suaza  
                    Started by RFrosty, 01-28-2026, 06:49 PM
                    0 responses
                    549 views
                    1 like
                    Last Post RFrosty
                    by RFrosty
                     
                    Working...
                    X