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 memonic, Yesterday, 01:23 PM
                    2 responses
                    12 views
                    0 likes
                    Last Post memonic
                    by memonic
                     
                    Started by merc410, Today, 03:41 AM
                    2 responses
                    13 views
                    0 likes
                    Last Post merc410
                    by merc410
                     
                    Started by sugalt, 04-30-2024, 04:02 AM
                    2 responses
                    13 views
                    0 likes
                    Last Post sugalt
                    by sugalt
                     
                    Started by Ndakotan1313, 03-14-2024, 05:02 PM
                    2 responses
                    64 views
                    0 likes
                    Last Post blaise_code  
                    Started by claxxical, 05-30-2017, 12:30 PM
                    37 responses
                    4,464 views
                    0 likes
                    Last Post Padan
                    by Padan
                     
                    Working...
                    X