NinjaScript > Educational Resources > Tips >

Parameter sequencing

Print this Topic Previous pageReturn to chapter overviewNext page

Indicator and strategy parameters (user defined inputs) will always be displayed in alphabetical order in any indicator/strategy dialog window as default behavior. If you ever come across the need to have these parameters sorted in a non-alphabetical order you can custom sort it by modifying the parameter's DisplayName tag.

 

In the NinjaScript Editor, expand the the "Properties" region of your code where all of your parameters are defined. In this example, this will be our our Properties section:

[Description("Number of standard deviations")]

[GridCategory("Parameters")]

public double NumStdDev

{

    get { return numStdDev; }

    set { numStdDev = Math.Max(0, value); }

}

 

[Description("Numbers of bars used for calculations")]

[GridCategory("Parameters")]

public int Period

{

    get { return period; }

    set { period = Math.Max(1, value); }

}

 

To sort the two parameters you can modify the DisplayName tag with "\t" excluding the quotations. "\t" will not be included as part of your parameter display but instead is used as a switch for the purpose of sorting. Cascading these switches will allow us to sort the parameters in whatever manner we wish.

 

For example, if we wanted "Period" to be before "Number of standard deviations" we would do this:

/// <summary>

/// </summary>

[Description("Number of standard deviations")]

[GridCategory("Parameters")]

[Gui.Design.DisplayName ("\t# of std. dev.")]

public double NumStdDev

{

    get { return numStdDev; }

    set { numStdDev = Math.Max(0, value); }

}

 

/// <summary>

/// </summary>

[Description("Numbers of bars used for calculations")]

[GridCategory("Parameters")]

[Gui.Design.DisplayName ("\t\tPeriod")]

public int Period

{

    get { return period; }

    set { period = Math.Max(1, value); }

}

 

Please take note that the first parameter to show up will be the parameter with the most "\t" cascaded in its DisplayName.

 

For more information on how to arrange the indicator/strategy's chart label, please see this reference sample: Removing and Custom Formatting an Indicator’s Chart Label