NinjaScript > Educational Resources > Tutorials > Indicators > Advanced - Custom Plot Colors via Thresholds >

Set Up

Print this Topic Previous pageReturn to chapter overviewNext page

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
Below you will define your indicators name and several indicator properties.




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 two parameters "Period" and "Smooth", enter the information as shown above
6. Press the "Next >" button


Defining Plots

Below you will define how your indicator is plotted on a chart.




7. Enter the information as shown above. Notice that we have added two plots. The "AboveZero" plot will be plotted if the indicator value is above zero and the "BelowZero" plot will be plotted if the indicator is below zero. We still have to add the NinjaScript code to make this possible which is coming later in the tutorial.

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. We are adding one oscillator line that will be plotted at a value of zero.

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 pre loaded 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. The default value of the "Period" and "Smooth" parameters are set in the "Variables" region of the code above Initialize().

3. This is the section that is called on each bar update (incoming tick) and is where you will enter your indicator logic