The first step in creating a custom indicator is to use the custom indicator wizard. The wizard will generate the required NinjaScript code that will serve as the foundation for your custom indicator.
1. Within the NinjaTrader Control Center window select the Tools-->New NinjaScript-->Indicator... menu
2. Press the "Next >" button
Defining Indicator Properties and Name
3. Enter the information as shown above
4. Press the "Next >" button
Defining Input Parameters
Below you will define your indicator's input parameters. These are any parameters that can be changed by the user and used in the calculation of the indicators value(s). If your indicator does not require any parameters leave the "Name" fields blank.
5. This indicator requires one parameter, Period, enter the information as shown above
Below you will define how your indicator is plotted on a chart.
7. Enter the information as shown above. Although the CCI indicator only has one plot, we have defined three plots above. This is because we are going to turn on/off the display of each plot depending on the actual CCI value. This will give the illusion that the CCI indicator line has three different colors.
8. Press the "Next >" button
Defining Oscillator Lines
Below you will define any required oscillator lines.
9. Enter the information as shown above. We are adding two refererence lines, one at +70 and the other at -70.
10. Press the "Next >" button
11. We are now finished entering in our indicator set up information. Press "Finish" button.
* At any time, you can press the "Generate" button in the wizard if you do not need to go through each of the wizard steps
You will now see the NinjaScript Editor preloaded with NinjaScript code generated by the wizard. It should look something like the image below.
Your primary area of concern will be sections "2" and "3".
1. This section provides the indicator with the chart display name and description used in the Indicator Dialog window.
2. The Initialize() section is processed only once when the indicator is initially loaded (added to a chart for example) and can be used to set up any indicator configuration requirements. You can see that this wizard generated code that added the plot color and style that we defined.
3. This is the section that is called on each bar update (incoming tick) and is where you will enter your indicator logic