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. 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.
8. Press the "Next >" button
Defining Oscillator Lines
Below you will define any required oscillator lines. This would be the "Zero" line in the CCI indicator for example. If your indicator does not require any oscillator lines leave the "Name" fields blank.
9. Enter the information as shown above (make sure the "Name" fields are blank since we do not need an oscillator line for a simple moving average indicator)
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 and set the default "Period" parameter that we define to 10.
3. This is the section that is called on each bar update (incoming tick) and is where you will enter your indicator logic