How To Build A Ninja Indicator - coding / programming - NinjaTrader Programming | futures trading

Go Back

> Futures Trading, News, Charts and Platforms > Platforms and Indicators > NinjaTrader > NinjaTrader Programming

How To Build A Ninja Indicator - coding / programming
Started:October 26th, 2009 (08:54 PM) by hondo69 Views / Replies:5,886 / 3
Last Reply:August 30th, 2013 (12:37 PM) Attachments:0

Welcome to

Welcome, Guest!

This forum was established to help traders (especially futures traders) by openly sharing indicators, strategies, methods, trading journals and discussing the psychology of trading.

We are fundamentally different than most other trading forums:
  • We work extremely hard to keep things positive on our forums.
  • We do not tolerate rude behavior, trolling, or vendor advertising in posts.
  • We firmly believe in openness and encourage sharing. The holy grail is within you, it is not something tangible you can download.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community. It's free and simple, and we will never resell your private information.

-- Big Mike

Thread Tools Search this Thread

How To Build A Ninja Indicator - coding / programming

Old October 26th, 2009, 08:54 PM   #1 (permalink)
Elite Member
Austin, TX
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: Currencies
hondo69's Avatar
Posts: 165 since Jun 2009
Thanks: 57 given, 238 received

How To Build A Ninja Indicator - coding / programming

Afraid of coding? - me too. Don't know what you're doing? - me neither. Don't let that stop you, it's not as hard as you think to develop a useful indicator. And its fun as well. Just follow this quick start guide.

Step 1 - Poke Around
Go to: Tools -> Edit Ninja Script -> Indicator

Find an indicator you've already downloaded and are familiar with. Open it up and look around. You'll quickly get a feel for the different "sections" of code. Then simply close that window and open another indicator and look at its sections of code. If you happen to open one with lots of code just close it and find one with only a little code. It will be easier to start with a simple code that you can borrow from later.

Step 2 - Roll Your Own
Once you've located a really simple indicator prepare to tweak it to see what happens. Start by opening the code and immediately right clicking within the code and select "save as". This is where you'll give your indicator it's own name (no spaces). Once saved you can edit or even delete this new indicator without worries of damaging some existing code.

Step 3 - Tweak Time
Tweak the existing code ever so slightly. Then you'll need to take 2 steps before you can see it live. Start by (a) saving the code by clicking the save button, then (b) click the compile button to build the final code. Now you can open the indicator in a chart to see how your changes behave. Then just rinse and repeat until you're happy.

Step 4 - Steal Code
The Ninja help file has some good code examples but falls short on explanations. They assume you already have a working knowledge of coding and often create more questions than answers. But the Ninja platform comes with some good example indicators that you can open and they have both good code and explanations of each section.

You can also borrow code from indicators posted on the Ninja forum and Big Mike's forum. Just be careful not to use code someone wants to keep private.

Another method is to go into the strategy analyzer and click on some things you'd like to see. Then click the "view code" button. It will open up the code itself without hurting the base file. Once you see the code you can copy and paste to see what happens.

Start with an indicator that is close to what you want to accomplish. The changes you'll need to make should be minor. But more importantly, all the "extras" you'll need are already in place.

These extras include thing like variables, data series, etc. that are a little tricky to set up for a first timer. By editing an indicator that is pretty close to what you want already you won't have to worry about the extras for now.

If the indicator performs several tasks at once like drawing dots and drawing a moving average don't worry if you only want the drawing dots part. It's OK to have extra code. You can "hide" the moving average part of it or even delete it if you feel brave. Just save the indicator as different versions along the way so you can always go back to a previous version when you make a mistake. And you'll make plenty. So get in the practice of adding a "version" to your file naming process.

Save the file as JoeV1 before any editing. Do a little editing then save as JoeV2. Keep saving as a new file as you edit and you'll be glad you did later since you'll surely box yourself into a corner sooner or later. Don't make the mistake of making a change then hitting the save button until you're sure. You can't "undo" after you've saved the file.

After you've made a few "easy" indicators you'll want to step up the complexity a bit. This gets a bit more heavy duty and I won't go into details here. The point is to dive in and poke around. You'll be surprised how easy it is to create something worthwhile.

Reply With Quote
The following 18 users say Thank You to hondo69 for this post:

Old October 26th, 2009, 09:22 PM   #2 (permalink)
Elite Member
Arcata, CA
Futures Experience: Intermediate
Platform: NinjaTrader
Favorite Futures: index futures, oil
Saroj's Avatar
Posts: 482 since Jun 2009
Thanks: 223 given, 379 received

Thanks, hondo... nice write-up... I added to the sticky post on coding tips and tricks

Reply With Quote

Old March 30th, 2012, 07:13 PM   #3 (permalink)
Elite Member
Newark, New Jersey, USA
Futures Experience: Beginner
Platform: NinjaTrader, ToS
Favorite Futures: 6E, ES
Posts: 6 since Sep 2010
Thanks: 21 given, 0 received

This is good stuff for a ninjascript beginner like me. I appreciate it.

Reply With Quote

Old August 30th, 2013, 12:37 PM   #4 (permalink)
Elite Member
Chicago, IL/USA
Futures Experience: Intermediate
Platform: Ninja Trader
Broker/Data: AMP Trading - CQG/ThinkorSwim
Favorite Futures: Futures
gretzkyless's Avatar
Posts: 29 since Jan 2013
Thanks: 11 given, 12 received


Not sure if you have included this in one of your links, but Mike did a great job showing how to create a strategy from scratch. I have included the link below.

I have watched this many times to get a refresher on points when creating a strategy. Any help like this is great. Thanks.

Plan your trade and trade your plan.
Reply With Quote
The following 2 users say Thank You to gretzkyless for this post:

Reply > Futures Trading, News, Charts and Platforms > Platforms and Indicators > NinjaTrader > NinjaTrader Programming > How To Build A Ninja Indicator - coding / programming

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Upcoming Webinars and Events (4:30PM ET unless noted)

An Afternoon with FIO trader bobwest

Elite only

NinjaTrader 8: Programming Profitable Trading Edges w/Scott Hodson

Elite only

Anthony Drager: Executing on Intermarket Correlations & Order Flow, Part 2

Elite only

Adam Grimes: Five critically important keys to professional trading

Elite only

Machine Learning Concepts w/FIO member NJAMC

Elite only

MarketDelta Cloud Platform: Announcing new mobile features

Dec 1

NinjaTrader 8: Features and Enhancements

Dec 6

Similar Threads
Thread Thread Starter Forum Replies Last Post
Visual Programming (programming without coding) LukeGeniol Platforms and Indicators 11 September 16th, 2016 12:49 PM
Ninja Programming - Useful Links Saroj NinjaTrader Programming 5 August 18th, 2011 04:09 PM
Ninja script - learning code + programming alias NinjaTrader Programming 20 May 11th, 2011 05:01 AM
Programming errors while importing Ninja script emini_Holy_Grail NinjaTrader Programming 8 May 20th, 2010 03:09 AM
Start programming / coding iwannatoscript NinjaTrader Programming 13 September 15th, 2009 11:42 AM

All times are GMT -4. The time now is 04:21 PM.

Copyright © 2016 by All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts

Page generated 2016-10-24 in 0.09 seconds with 19 queries on phoenix via your IP