Welcome to NexusFi: the best trading community on the planet, with over 150,000 members Sign Up Now for Free
Genuine reviews from real traders, not fake reviews from stealth vendors
Quality education from leading professional traders
We are a friendly, helpful, and positive community
We do not tolerate rude behavior, trolling, or vendors advertising in posts
We are here to help, just let us know what you need
You'll need to register in order to view the content of the threads and start contributing to our community. It's free for basic access, or support us by becoming an Elite Member -- see if you qualify for a discount below.
-- Big Mike, Site Administrator
(If you already have an account, login at the top of the page)
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.
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.
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.