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

How to set instrument in code...

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

    How to set instrument in code...

    I am new to Ninjatrader, but have written C# professionally for many years.

    Can someone tell me how to set the instrument in code? I'd like to evaluate mulitple instruments without having to use the UI, and would most likely setup my code as a strategy.

    Thanks!!

    bob

    #2
    There are a few Sample Automated Strategies which come pre-configured in NinjaTrader that you can use as a starting point. These are found under Tools--> Edit NinjaScript--> Strategy. You will see locked strategies where you can see the details of the code, but you will not be able to edit (you can though always create copies you can later edit via right click > Save as)

    We also have some Reference samples online as well as ‘Tips and Tricks’ for both indicators and strategies:
    Click here to see our NinjaScript Reference Samples
    Click here to see our NinjaScript Tips


    These samples can be downloaded, installed and modified from NinjaTrader and hopefully serve as a good base for your custom works.

    We have a fully documented help guide which will help you get started with Ninja Script. You will find language references to all of the methods and functions you will be using. You will also see a tutorial section which will help you create your first indicator and get you started with some of these concepts.

    A link to our Help Guide can be found below: http://www.ninjatrader.com/support/h...stribution.htm

    I am also linking you to the Educational Resources section of the Help Guide to help you get started with NinjaScript: http://www.ninjatrader.com/support/h..._resources.htm

    There is a also a growing library of user submitted custom indicators (100+) that can be downloaded from our support form. Please look in the NinjaScript File Sharing section of our support forum as you may find what you are looking for there.

    If you have limited time or programming capabilities, you can discuss your requirements with any of our certified NinjaScript consultants.
    Click here for a list of certified NinjaScript Consultants
    LanceNinjaTrader Customer Service

    Comment


      #3
      RE: How to set an instrument in Code

      Thank you for your generic guidance. But I was wondering if someone could answer my question?

      It seems on the surface that you have to determine the instrument in advance as part of the UI before you run a strategy against that instrument, and then you can have access to the Bars, (High, Low, Close, etc.) of that instrument. I'm looking for a way to setup an instrument without using your UI, but then use all of the classes, etc. that are available.

      I see how you can use the Initialize method to add other instruments: (see below)

      Add(Instrument, PeriodType.Minute, 5);

      So I guess I am wondering if you can use "Add()" in other places in the strategy (not just the Initialize method). And if so, is there a "Remove()" method (I don't see one in the Docs).

      Thank You!!

      bob

      Comment


        #4
        I apologize I must have miss-read your post the first time around. When you're creating a strategy it will be run from a chart or the strategies tab. This determines the primary instrument for the strategy. If you need to reference data from another series you can do so by adding them in Initialize()

        The opposite "Remove()" does not exist in this context and Add() is only used in Initialize()

        If you're wanting to work with multiple instruments/time frames within one strategy you will want to read the following section: http://www.ninjatrader.com/support/h...nstruments.htm

        This will further explain how to reference different series. The primary instrument will always be set via the UI. If you needed to you could ignore the primary series in your code and force it to use the secondary/tertiary as needed.
        LanceNinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by algospoke, Yesterday, 06:40 PM
        2 responses
        23 views
        0 likes
        Last Post algospoke  
        Started by ghoul, Today, 06:02 PM
        3 responses
        14 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by jeronymite, 04-12-2024, 04:26 PM
        3 responses
        45 views
        0 likes
        Last Post jeronymite  
        Started by Barry Milan, Yesterday, 10:35 PM
        7 responses
        22 views
        0 likes
        Last Post NinjaTrader_Manfred  
        Started by AttiM, 02-14-2024, 05:20 PM
        10 responses
        181 views
        0 likes
        Last Post jeronymite  
        Working...
        X