NinjaScript > Educational Resources > Tips > Creating User Defined Input Parameters |
|
You can create user defined input parameters for both NinjaScript Indicators and Strategies. Although user defined input parameters can be specified as part of the initial set up of NinjaScript Indicator or Strategies using the Wizard you may have a requirement to add new parameters at a later point in your development process. To create these parameters you will need to edit your NinjaScript code and follow these steps. 1. Open your NinjaScript file 2. Expand the minimized “Variables” section of your code and create a private variable for your parameter
Note: This is also where you set the default value for your parameter. 3. Scroll down to the bottom of the editor and expand the minimized “Properties” section by clicking on the + sign on the left. 4. Use the following template code for each parameter you wish to create
Note: In the "get" and "set" lines make sure you use the private variable you created in step 2. 5. Use the "Description" field to provide a brief description of what the parameter does. Use the “GridCategory” field to group similar parameters together 6. Pay attention to this line as the object type will vary depending on the type of parameter you wish to make:
7. In the "set" line, simply set it to “value” if you do not wish to create a lower bound for the parameter
Note: If you wish to set an upper bound use Math.Min()
8. Now, wherever in your code you want to call the user-definable parameter, just use "Period".
|