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

Sample scripts

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

    Sample scripts

    I remember working through some simple "from scratch" scripts for NT7 which were accompanied by detailed explanations for the non-programmer. Does anything like that exist for NT8?

    #2
    Hello sgordet,

    NinjaScript is written in C# 8 targeting .NET 4.8.

    If you would like to take on learning NinjaScript, we have a fully documented help guide which will help you get started.

    In the help guide there are 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.


    The best way to begin learning NinjaScript is to use the Strategy Builder. With the Strategy Builder you can setup conditions and variables and then see the generated code in the NinjaScript Editor by clicking the View Code button.

    This is a powerful tool. The best way to be introduced, would be to follow along with our 'Automate Your Trading with NinjaTrader's Strategy Builder' tutorial which shows you how the tool can be used to create a simple strategy that can then be tested.

    I recommend starting here, and then to start making simple strategies just to test out one or two conditions so you can be sure that you have the conditions set up appropriately. It is important to start small and to test as you go to ensure that the logic is working before you scale up and add more complexity to the strategy.

    I'm providing a link to the 'Automate Your Trading with NinjaTrader's Strategy Builder' training for you to view at your own convenience.
    Automate Your Trading with NinjaTrader's Strategy Builder - https://www.youtube.com/watch?v=VxU4...We0Nf&index=11

    As well as links to the help guide with example conditions that can be setup in the Strategy Builder.
    Conditions examples —https://ninjatrader.com/support/help...on_builder.htm
    Actions examples — https://ninjatrader.com/support/help...us/actions.htm

    For diving further into the C# code of an unlocked strategy or indicator, the NinjaScript Editor 401 is an overview of the syntax and debugging.
    NinjaScript Editor 401 - https://www.youtube.com/watch?v=H7aD...ZmVnauWXkWe0Nf


    Next up is a link to a set of specific tutorials for creating conditions in the NinjaTrader 8 Strategy Builder in the NinjaTrader 8 help guide:
    https://ninjatrader.com/support/help...on_builder.htm

    The entire Alphabetical Reference can be found with the following link:
    http://ninjatrader.com/support/helpG..._reference.htm

    Below are links to Reference Samples online as well as some Tips and Tricks for both indicators and strategies. These samples can be downloaded, installed and modified from NinjaTrader and hopefully serve as a good base for your custom works.

    Click here to see our NinjaScript Reference Samples:
    https://ninjatrader.com/support/help...ce_samples.htm

    Click here to see our NinjaScript Tips:


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


    All links to 3rd party educational resources below are publicly available.

    If you are new to C#, to get a basic foundation for the concepts and syntax used in NinjaScript I would recommend this section of articles in our help guide first:
    http://ninjatrader.com/support/helpG...g_concepts.htm

    And the MSDN (Microsft Developers Network) C# Language Reference.
    https://ninjatrader.com/support/help..._reference.htm

    I have personally found DotNetPerls to be a very helpful 3rd party educational resource with simple, direct, and easy to follow examples.
    Browse examples for many languages, with explanations and code side by side for easy understanding.


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


    Use the Intelliprompt to see how methods can be called (Ctrl + Space to view overload signatures) and what properties are available to an object.
    https://ninjatrader.com/support/help...elliprompt.htm

    Last, I'm also sharing a link to another forum post that reviews how to use prints to understand behavior and debug a script when the behavior is unexpected.
    http://ninjatrader.com/support/forum...979#post510979


    Other useful resources on learning C#:
    NinjaScript Debugging
    Dot Net Perls
    W3Schools
    Softsteel Soluions
    CSharp Essentials
    C# Station
    The Code Project
    Channel 9 C# Fundamentals
    Pluralsight

    Please note, in the support department at NinjaTrader it is against our policy to create, debug, or modify, code or logic for our clients. Further, we do not provide C# programming education services in our support. This is so that we can maintain a high level of service for all of our clients as well as our partners.

    C# programming education comes prerequisite to writing NinjaScript code. The Strategy Builder can be used to see how it generates C# syntax, but please be aware that it is not with our Scripting Support team's scope to provide programming education services or to check your syntax. We highly recommend getting further acquainted with C# through a formal class, or through educational resources that can be found external to NinjaTrader.


    Please let me know if you have any questions.


    The NinjaTrader Ecosystem website is for educational and informational purposes only and should not be considered a solicitation to buy or sell a futures contract or make any other type of investment decision. The add-ons listed on this website are not to be considered a recommendation and it is the reader's responsibility to evaluate any product, service, or company. NinjaTrader Ecosystem LLC is not responsible for the accuracy or content of any product, service or company linked to on this website.
    Last edited by NinjaTrader_ChelseaB; 06-07-2022, 02:52 PM.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      For help with automatic conversion of NT7 indicators to NT8 --> study this.

      Comment


        #4
        EXCELLENT INFORMATION, Chelsea. Thanks much!

        Comment


          #5
          ChelseaB I'm going step by step in video NinjaScript 401 but I'm getting two issues...

          privateSMA SMA1;
          private SMA SMA2;
          private PPO PPO1; This ?

          And errors when I copy/paste properties.

          You can see everything in this video and what I may be doing wrong.



          Thank you, sir.
          Last edited by trdninstyle; 10-17-2022, 12:27 PM.

          Comment


            #6
            Hello trdninstyle,

            In the video you are not pasting the code in the same place that the original script has it, you need to paste it below OnBarUpdates closing brace }
            JesseNinjaTrader Customer Service

            Comment


              #7
              Hello Jesse, Okay, I did it correct this time. Now I can go back to that video and keep watching it. Thank you thank you.

              Almost forgot, in pic u can see I have an extra item than what the 401-video had.
              Attached Files
              Last edited by trdninstyle; 10-15-2022, 04:00 PM.

              Comment


                #8
                Hello trdninstyle,

                The line you have pointed out in the pictures are called variables and would be used later for the indicators used in the sample that you are using.

                If you are having trouble following the video you can also use the strategy builder video first which shows how to auto generate indicator code/variables and user inputs. Once you have made some basic conditions in the builder you can click view code to see the generated NinjaScript or press Unlock code if you wanted to manually code it from that point.

                JesseNinjaTrader Customer Service

                Comment


                  #9
                  Thank you, Jesse,

                  I value your help. Inside this pic I placed video 401 Indicator Variable next to the variable that I got, and I somehow ended up with the extra one that u see there.

                  I suspect that I may of err in the Inputs & Variables process or the User Inputs for the user, Conditions & Actions?
                  Do u see the extra one that I have on mine? I have an arrow pointing to it.
                  Thank you, my good sir.
                  Attached Files

                  Comment


                    #10
                    Hello trdninstyle,

                    I see the variable however I wouldn't know what to advise here. If you need that variable because you use that indicator then you can keep that code. If you don't need that variable because you don't use that indicator you can remove it.

                    I would suggest using the strategy builder to generate code if you are unsure which variables you need to keep. The builder generates all necessary variables based on the conditions you make. You can then reference the generated variables to see which you need based on the conditions using indicators.
                    JesseNinjaTrader Customer Service

                    Comment


                      #11
                      Jesse,

                      Simple question. I can't figure out how to make that straight line thats in the pic.
                      Attached Files

                      Comment


                        #12
                        Hello trdninstyle,

                        That is the pipe character, its on the keyboard below the backspace key. You would hold shift to get use that character when pressing the slash.

                        JesseNinjaTrader Customer Service

                        Comment


                          #13
                          Thank you for that. I never had to use it didn't know it was there.

                          Comment


                            #14
                            Hello Jesse, I started to ask what this meant but I just figured it out, had to make changes in the Conditions & Actions.
                            But my next question is about more complex strategies using price action with swing structure rather than moving averages.
                            Do u guys have videos using Price inputs & variables?

                            Attached Files

                            Comment


                              #15
                              Hello trdninstyle,

                              The image you provided, you are getting that warning because the input is still used in one of the sets or with the stops/targets. To edit or remove inputs you need to completely remove it from all sets/ stops and targets page.

                              You can view the strategy builder webinar however that just explains in general how to use that page to add user inputs or variables.

                              JesseNinjaTrader Customer Service

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by adeelshahzad, Today, 03:54 AM
                              5 responses
                              32 views
                              0 likes
                              Last Post NinjaTrader_BrandonH  
                              Started by stafe, 04-15-2024, 08:34 PM
                              7 responses
                              32 views
                              0 likes
                              Last Post NinjaTrader_ChelseaB  
                              Started by merzo, 06-25-2023, 02:19 AM
                              10 responses
                              823 views
                              1 like
                              Last Post NinjaTrader_ChristopherJ  
                              Started by frankthearm, Today, 09:08 AM
                              5 responses
                              21 views
                              0 likes
                              Last Post NinjaTrader_Clayton  
                              Started by jeronymite, 04-12-2024, 04:26 PM
                              3 responses
                              43 views
                              0 likes
                              Last Post jeronymite  
                              Working...
                              X