• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

The Indicator Club

  • Indicators
    • All Indicators
    • Free Indicators
    • Join the Club!
    • Indicator TImeline
  • Blog
    • All
    • NinjaScript Tutorials
    • Trade Ideas
    • Free Strategies
    • Favorite Posts
  • FAQ
  • My Account
    • Activate License
    • API Keys
    • API Downloads
  • Contact
  • Cart

June 27, 2017 by The Indicator Club 3 Comments

Getting Started with NinjaScript

Brief Introduction

We’ve put together a series of posts to help you in your journey to learn how to program from scratch, or edit existing NinjaTrader indicators and strategies. All of our posts are geared toward the non-programmer, so even though we will present a lot of information, for all of you more technical people out there, we will not go into all the technicalities of C#, NinjaTrader, or NinjaScript. It’s also important to note that even though we show you how to do something in NinjaTrader, that is by no way the only way to do it. We will present what has worked best for us and what will be most easily understood by someone learning how to program. Finally, for the more advance users, we are going to leave things out and over simplify certain parts because we are focused on learning what we need to so we can get started on our NinjaScript journey.

NinjaScript is NinjaTrader’s programming language and is based on C#. What that means is most C# concepts can be applied directly to NinjaTrader, but there are also built-in Methods that are unique to NinjaTrader. This may sound overwhelming and you may start thinking you need to learn C#, but I can assure you that to get started programming NinjaScript, you do not need to learn C# to code a lot of great indicators. All you need to do, for now, is stick with learning through our posts and as concepts come up that you don’t fully understand, do research on your own (I am continually doing research, even years later)!

NinjaScript Editor

All of our development will occur inside of NinjaTrader (even though you could do this through other programs), so first start NinjaTrader 8 and on the Control Center go to New -> NinjaScript Editor. You should now have a new window appear that says “NinjaScript Editor” in the top left hand corner.

Create Indicator

Now it is time to create an indicator, so in the NinjaScript Editor, right-click on the folder (on the right) called “Indicator” and click New Indicator. A new window should appear that looks like this:

Click the Next button and then fill out the indicator Name and Description, as follows:

Once you have filled out your Name and Description, click Next and fill out the settings like this (we will get into the details behind the below options in a later post):

Finally, click Generate and our new indicator will appear in the NinjaScript Editor as follows:

Basic Indicator Layout

It’s time to look at the basic layout of all (almost all) NinjaTrader indicators. In most of the examples, I will post code that you can easily copy and paste into your NinjaScript Editor. Also, a lot of my explanation will occur as “comments” in the code itself. Copy and paste the below code into your indicator and see what happens:

Save and Compile

The last thing to do for Part 1 is to Save your work and Compile. There are several ways you can save, Ctrl + S, right-click and choose save, or in the toolbar there is a save icon. Once your indicator is saved, right-click on the indicator editor and choose compile, or choose compile from the toolbar (has a “>” in the icon). When you compile your indicator, NinjaTrader will check the code for errors (errors can still occur once we place the indicator on the chart), but after the code is checked for errors, NinjaTrader will go through its internal process(es) so you can choose the indicator from the indicator window (when you are adding indicators to a chart) and reference the indicator from another indicator. Checkout Part 2 – Declaring Variables.

Filed Under: Tutorial Tagged With: Learn, NinjaScript

Reader Interactions

Comments

  1. Don Gay says

    August 4, 2018 at 9:24 pm

    Where in the indicator do I paste the code? I tried 2 different places but both result in errors and refuse to compile until the errors are corrected. Thanks.

    Reply
    • The Indicator Club says

      August 6, 2018 at 7:55 pm

      After you click generate and the NinjaScript Editor appears, copy and paste the code in this post over all the code that is in the NinjaScript Editor and compile (I just tried this on 8.0.15.0 and had no issues).

      Reply
      • Don Gay says

        August 12, 2018 at 8:15 am

        Thank you! I hadn’t considered the possibility that the instructions were to REPLACE existing code with the code they wanted pasted in.

        Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Primary Sidebar

Recent Posts

  • Top Shelf Trader October 6, 2017
  • Use Any Indicator with Our Frameworks: Universal Inputs September 21, 2017
  • NinjaTrader Training: Part 10: Coloring Plots and Backgrounds September 1, 2017
  • NinjaTrader Training: Part 9 – AddPlot and Plot Variables August 31, 2017
  • NinjaTrader Training: Part 8 – Referencing Indicators August 30, 2017

Post Tags

Advance Internals Automated Backtest Day Trading Detrend Forex Trading Free Futures Trading Learn Moving Average MTF NinjaScript NinjaTrader 7 NInjaTrader 8 Oscillator Pivot Points RSI Stock Trading Strategy Vix Trend Volume

Footer

WHO WE ARE

The Indicator Club is made up of normal traders and professional software developers who want to share their indicators for a fraction of the cost it would take to code just one!

The Indicator Club

Purchase & Support

To get access to all of our current and future indicators and strategies, check out our Complete Package.

If you need support please email [email protected], or head over to our contact page.

New Releases

  • NinjaTrader 8 Osc Universal Input Osc Universal Input $497.00
  • NinjaTrader 8 MA Universal Input MA Universal Input $497.00
  • NinjaTrader 8 Bar Orders Bar Orders $297.00
  • NinjaTrader 8 Tick Offset Tick Offset $0.00

Recent Posts

  • Top Shelf Trader
  • Use Any Indicator with Our Frameworks: Universal Inputs
  • NinjaTrader Training: Part 10: Coloring Plots and Backgrounds
  • NinjaTrader Training: Part 9 – AddPlot and Plot Variables

Copyright ©2020 | All Rights Reserved | By Using This Site you Agree to our Terms and Conditions, Risk Disclosures, and Software Agreement

NinjaTrader Disclosure: NinjaTrader® is a registered trademark of NinjaTrader Group, LLC. No NinjaTrader company has any affiliation with the owner, developer, or provider of the products or services described herein, or any interest, ownership or otherwise, in any such product or service, or endorses, recommends or approves any such product or service.

RISK DISCLOSURE: Futures and forex trading contains substantial risk and is not for every investor. An investor could potentially lose all or more than the initial investment. Risk capital is money that can be lost without jeopardizing ones financial security or life style. Only risk capital should be used for trading and only those with sufficient risk capital should consider trading. Past performance is not necessarily indicative of future results.

HYPOTHETICAL PERFORMANCE DISCLAIMER: HYPOTHETICAL PERFORMANCE RESULTS HAVE MANY INHERENT LIMITATIONS, SOME OF WHICH ARE DESCRIBED BELOW. NO REPRESENTATION IS BEING MADE THAT ANY ACCOUNT WILL OR IS LIKELY TO ACHIEVE PROFITS OR LOSSES SIMILAR TO THOSE SHOWN; IN FACT, THERE ARE FREQUENTLY SHARP DIFFERENCES BETWEEN HYPOTHETICAL PERFORMANCE RESULTS AND THE ACTUAL RESULTS SUBSEQUENTLY ACHIEVED BY ANY PARTICULAR TRADING PROGRAM. ONE OF THE LIMITATIONS OF HYPOTHETICAL PERFORMANCE RESULTS IS THAT THEY ARE GENERALLY PREPARED WITH THE BENEFIT OF HINDSIGHT. IN ADDITION, HYPOTHETICAL TRADING DOES NOT INVOLVE FINANCIAL RISK, AND NO HYPOTHETICAL TRADING RECORD CAN COMPLETELY ACCOUNT FOR THE IMPACT OF FINANCIAL RISK OF ACTUAL TRADING. FOR EXAMPLE, THE ABILITY TO WITHSTAND LOSSES OR TO ADHERE TO A PARTICULAR TRADING PROGRAM IN SPITE OF TRADING LOSSES ARE MATERIAL POINTS WHICH CAN ALSO ADVERSELY AFFECT ACTUAL TRADING RESULTS. THERE ARE NUMEROUS OTHER FACTORS RELATED TO THE MARKETS IN GENERAL OR TO THE IMPLEMENTATION OF ANY SPECIFIC TRADING PROGRAM WHICH CANNOT BE FULLY ACCOUNTED FOR IN THE PREPARATION OF HYPOTHETICAL PERFORMANCE RESULTS AND ALL WHICH CAN ADVERSELY AFFECT TRADING RESULTS.