NexusFi: Find Your Edge


Home Menu

 





How To Build A Ninja Indicator - coding / programming


Discussion in NinjaTrader

Updated
      Top Posters
    1. looks_one gretzkyless with 1 posts (2 thanks)
    2. looks_two hondo69 with 1 posts (20 thanks)
    3. looks_3 Saroj with 1 posts (0 thanks)
    4. looks_4 tassog with 1 posts (0 thanks)
    1. trending_up 14,544 views
    2. thumb_up 22 thanks given
    3. group 6 followers
    1. forum 3 posts
    2. attach_file 0 attachments




 
Search this Thread

How To Build A Ninja Indicator - coding / programming

  #1 (permalink)
 
hondo69's Avatar
 hondo69 
Austin, TX
 
Experience: Intermediate
Platform: NinjaTrader
Trading: Currencies
Posts: 162 since Jun 2009
Thanks Given: 57
Thanks Received: 248

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.

NOTES
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.

Started this thread Reply With Quote

Can you help answer these questions
from other members on NexusFi?
REcommedations for programming help
Sierra Chart
Pivot Indicator like the old SwingTemp by Big Mike
NinjaTrader
ZombieSqueeze
Platforms and Indicators
Better Renko Gaps
The Elite Circle
Exit Strategy
NinjaTrader
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Spoo-nalysis ES e-mini futures S&P 500
29 thanks
Just another trading journal: PA, Wyckoff & Trends
25 thanks
Tao te Trade: way of the WLD
24 thanks
Bigger Wins or Fewer Losses?
21 thanks
GFIs1 1 DAX trade per day journal
17 thanks
  #2 (permalink)
 
Saroj's Avatar
 Saroj 
Arcata, CA
 
Experience: Intermediate
Platform: NinjaTrader
Trading: index futures, oil
Posts: 485 since Jun 2009
Thanks Given: 232
Thanks Received: 415

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

Reply With Quote
  #3 (permalink)
 tassog 
Newark, New Jersey, USA
 
Experience: Beginner
Platform: NinjaTrader, ToS
Trading: 6E, ES
Posts: 6 since Sep 2010
Thanks Given: 21
Thanks Received: 0


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

Reply With Quote
  #4 (permalink)
 
gretzkyless's Avatar
 gretzkyless 
Chicago, IL/USA
 
Experience: Intermediate
Platform: Ninja Trader
Broker: AMP Trading - CQG/ThinkorSwim
Trading: Futures
Posts: 30 since Jan 2013
Thanks Given: 13
Thanks Received: 19

Saroj:

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.
Follow me on Twitter Reply With Quote
Thanked by:




Last Updated on August 30, 2013


© 2024 NexusFi™, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
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.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Privacy Policy - Downloads - Top
no new posts