Framework Reference
WEALTHLAB FRAMEWORK / CLASS REFERENCE

Parameter

API documentation, members, signatures, and C# examples.

Search the framework

Find classes, members, and documentation.

NamespaceWealthLab.Core
Parent
Steppable

The Parameter class represents a configurable value used throughout WealthLab, most commonly in C# Coded Strategies and custom indicators derived from IndicatorBase. Each Parameter has a Name, Type, Value, and DefaultValue. In C# Coded Strategies, Parameters can be optimized by defining MinValue, MaxValue, and StepValue. In custom indicators, Parameters define values that users can configure when working with the indicator in a chart or Building Block Strategy.

AsType Helper Properties

13

AsBarHistory

public BarHistory AsBarHistory

Returns the Parameter's Value as a BarHistory instance. This is intended for a Parameter whose Type is ParameterType.BarHistory.

AsBoolean

public bool AsBoolean

Returns the Parameter's Value as a bool. This is intended for a Parameter whose Type is ParameterType.Boolean.

AsColor

public WLColor AsColor

Returns the Parameter's Value as a WLColor instance. This is intended for a Parameter whose Type is ParameterType.Color.

AsDataRange

public DataRange AsDataRange

Returns the Parameter's Value as a DataRange instance. This is intended for a Parameter whose Type is ParameterType.DataRange.

AsDate

public DateTime AsDate

Returns the Parameter's Value as a DateTime. This is intended for a Parameter whose Type is ParameterType.Date.

AsDouble

public double AsDouble

Returns the Parameter's Value as a double. Int32 values are also converted to double.

AsFont

public WLFont AsFont

Returns the Parameter's Value as a WLFont instance. This is intended for a Parameter whose Type is ParameterType.Font.

AsHistoryScale

public HistoryScale AsHistoryScale

Returns the Parameter's Value as a HistoryScale instance. This is intended for a Parameter whose Type is ParameterType.HistoryScale.

AsInt

public int AsInt

Returns the Parameter's Value as an int. String values are parsed when possible, and double values are converted to int.

AsLineStyle

public LineStyle AsLineStyle

Returns the Parameter's Value as a LineStyle value.

AsPriceComponent

public PriceComponent AsPriceComponent

Returns the Parameter's Value as a PriceComponent value.

AsString

public string AsString

Returns the Parameter's Value as a string. If the Value is an Enum, its string representation is returned. A null Value returns an empty string.

Constructors

1

Parameter

public Parameter(string name, ParameterType type, object value)
public Parameter(string name, ParameterType type, object value, double minValue, double maxValue, double stepValue = 1.0)
public Parameter(string name, Type enumType)

The first constructor creates a Parameter with the specified name, type, and initial value. The second additionally defines the MinValue, MaxValue, and StepValue used when the Parameter is optimized. The third constructor creates a ParameterType.StringChoice Parameter from an Enum type. Its Choices List is automatically populated with the names of the Enum values. In C# Coded Strategies you normally create Parameters using the AddParameter method of UserStrategyBase rather than instantiating Parameter directly. Custom indicators derived from IndicatorBase similarly provide an AddParameter method.

Members

24

AssignExplicitValues

public void AssignExplicitValues(IEnumerable<double> values)
public void AssignExplicitValues(params object[] vals)

Assigns an explicit set of optimization values to the Parameter instead of deriving the values from MinValue, MaxValue, and StepValue. The first overload accepts an IEnumerable<double>, such as a List<double> or double array. The second accepts Int32 or double values directly. The values are sorted before being used.

AssignFibonacciValues

public void AssignFibonacciValues()

Assigns explicit optimization values consisting of the Fibonacci numbers that fall between the Parameter's MinValue and MaxValue. The Parameter must already have a defined minimum and maximum range.

AssignPercentageValues

public void AssignPercentageValues(double percentageGain)

Assigns explicit optimization values beginning at MinValue, with each subsequent value increased by percentageGain percent. This is useful for producing logarithmically increasing optimization values. The Parameter must already have defined MinValue and MaxValue values, and percentageGain must be greater than zero.

Choices

public List<string> Choices

Contains the available choices for a Parameter whose Type is ParameterType.StringChoice. Add the desired strings to this collection when creating a StringChoice Parameter manually. The Enum-based Parameter constructor populates this List automatically.

DefaultValue

public object DefaultValue

Contains the initial value assigned when the Parameter was created. Unlike Value, DefaultValue is not changed when the Parameter is modified by an optimization or through the user interface.

FindClosestMatch

public double FindClosestMatch(double value)

Returns the available Parameter value that is closest to value. If no matching Parameter value can be found, the supplied value itself is returned.

Hint

public string Hint

Contains optional explanatory text for the Parameter. The hint is displayed as a tooltip when the user hovers over the Parameter in the Strategy Settings interface.

IsChecked

public bool IsChecked

Indicates whether the Parameter is enabled for optimization. The default value is true.

IsReadOnly

public bool IsReadOnly

When true, prevents the Parameter's start, stop, and step values from being changed in the optimization parameter editor.

MakeOptimizable

public bool MakeOptimizable

Indicates whether the Parameter should be made optimizable when it is used in a Building Block Strategy.

MaxValue

public double MaxValue

Contains the maximum value of the Parameter's optimization range.

MinValue

public double MinValue

Contains the minimum value of the Parameter's optimization range.

Name

public string Name

The descriptive name of the Parameter.

OptimizedValues

public UniqueList<double> OptimizedValues

Contains the values that have been used to optimize this Parameter.

Permutations

public ulong Permutations

Returns the number of possible optimization values for the Parameter. If IsChecked is false, Permutations returns 1 because the Parameter does not contribute additional permutations to the optimization.

PossibleValues

public List<double> PossibleValues

Returns a List<double> containing the possible values that the Parameter can assume.

StepValue

public double StepValue

Contains the increment used when generating optimization values. An optimization normally tests values beginning at MinValue, continuing through MaxValue, and incrementing by StepValue.

StringChoiceIndex

public int StringChoiceIndex

For a Parameter whose Type is ParameterType.StringChoice, returns the index in Choices of the currently selected value.

Type

public ParameterType Type

Specifies the data type represented by the Parameter's Value. See the Enums reference for the available ParameterType values.

TypeName

public string TypeName

Returns the name of the Parameter's type. For Parameters created from an Enum, TypeName is used to retain the Enum type information.

ValidateStartStopStep

public void ValidateStartStopStep()

Validates the Parameter's optimization range. The method throws an InvalidOperationException if StepValue is zero or negative, or if MinValue is greater than MaxValue.

Value

public object Value

Contains the current value of the Parameter. The Value can differ from DefaultValue, for example when a Strategy Parameter is changed by the user or assigned a different value during an optimization.

Values

public List<double> Values

Returns the numeric values that the Parameter can assume. Normally these values are generated from MinValue, MaxValue, and StepValue. If explicit values have been assigned using AssignExplicitValues, AssignFibonacciValues, or AssignPercentageValues, those values are returned instead.

ValuesDescription

public string ValuesDescription

Returns a textual description of the Parameter's available optimization values, including the number of values and a representation of the values themselves.

Need help with this API?

Ask the community or explore custom development services.