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

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 aussugardefender, Today, 01:07 AM
                    0 responses
                    1 view
                    0 likes
                    Last Post aussugardefender  
                    Started by pvincent, 06-23-2022, 12:53 PM
                    14 responses
                    238 views
                    0 likes
                    Last Post Nyman
                    by Nyman
                     
                    Started by TraderG23, 12-08-2023, 07:56 AM
                    9 responses
                    383 views
                    1 like
                    Last Post Gavini
                    by Gavini
                     
                    Started by oviejo, Today, 12:28 AM
                    0 responses
                    1 view
                    0 likes
                    Last Post oviejo
                    by oviejo
                     
                    Started by pechtri, 06-22-2023, 02:31 AM
                    10 responses
                    125 views
                    0 likes
                    Last Post Leeroy_Jenkins  
                    Working...
                    X