API documentation, members, signatures, and C# examples.
Search the framework
Find classes, members, and documentation.
NamespaceWealthLab.Backtest
Parent
Object
The Strategy class contains a WealthLab Strategy's code or rules, metadata, backtest configuration, optimization settings, and compiled StrategyBase instance.
The Backtester exposes the Strategy being tested through Backtester.Strategy, which can be useful for inspecting settings such as PositionSize, Benchmark, DataSetName, Scale, and DataRange.
Warning: Strategy settings should generally be treated as read-only from Strategy execution code. Changing them while a backtest is running can produce unexpected results.
Returns a BacktestSettings instance representing the Strategy's backtest-related settings.
The returned instance is cloned from the global BacktestSettings and updated with the Strategy's RetainNSF and GranularLimitStopScale settings.
Gets or sets the intraday scale used for granular processing of limit and stop orders.
A Daily scale indicates that granular processing is disabled.
See also UpdateGranularData.
Gets or sets the compiled StrategyBase instance associated with this Strategy.
Assigning a non-null instance also updates CouldOptimize based on CanOptimize.
Gets or sets the type name associated with a compiled Strategy.
When CompiledStrategy is available and StrategyType is Compiled, the property's getter returns the runtime type name of CompiledStrategy.
Creates the CompiledStrategy instance for a Strategy whose StrategyType is StrategyType.Compiled.
If StrategyData is not empty, it is parsed into the newly created StrategyBase instance.
Creates and returns the compiled StrategyBase instance represented by this Strategy.
The behavior depends on StrategyType:
Compiled - Creates the corresponding compiled Strategy instance.
Rotation - Creates a RotationStrategy.
TradeHistory - Creates a TradeHistoryStrategy.
MetaStrategy - Creates a MetaStrategy.
Code - Compiles the C# source in StrategyData.
BuildingBlock - Generates C# code from the Building Block Strategy and compiles it.
Compiler and parameter validation errors are placed in CompilerErrors.
Creates and returns a new UserStrategyBase instance having the same runtime type as the Strategy's compiled UserStrategyBase.
Returns null if a suitable compiled UserStrategyBase cannot be obtained.
Gets or sets the default C# source code used when creating a new Code Strategy.
WealthLab first attempts to load the template from DefaultTemplateCode.txt in the WealthLab data folder. If the file is not present, the built-in Strategy template is used.
Assigning a non-empty value updates the template and writes it to the template file.
Returns an executable StrategyBase instance.
For a UserStrategyBase-derived Strategy, WealthLab creates a fresh UserStrategyBase instance and wraps it in a UserStrategyExecutor.
For other StrategyBase types, CreateInstance is used.
Returns null if no CompiledStrategy is available.
Creates a Strategy.
The parameterless constructor initializes the Strategy using the current StrategyFactory defaults and sets IsNewlyCreated to false.
The second overload initializes the Strategy and sets IsNewlyCreated to the value of newlyCreated.
The StrategyType overload creates a newly created Strategy of the specified type. For a Code Strategy, StrategyData is initialized with DefaultTemplateCode. For a Building Block Strategy, StrategyData is initialized with a new Building Block Strategy definition.
Creates and returns a copy of the Strategy.
The preserveWLDownloadFlag parameter determines whether WealthLab.com publication and user Strategy flags are preserved.
Copies information from source into this Strategy.
When copySettingsOnly is false, Strategy identity, metadata, StrategyData, compiled Strategy information, and settings are copied.
When copySettingsOnly is true, the operation primarily copies Strategy configuration while preserving the receiving Strategy's identity and Strategy definition.
The preserveWLDownloadFlag parameter determines whether WealthLab.com-related Strategy flags are copied.
Returns the glyph resource associated with the Strategy's StrategyType.
The returned glyph differs for Building Block, C# Code, Rotation, MetaStrategy, Compiled, and Trade History Strategies.
Returns the Strategy's last save date.
For non-compiled Strategies, WealthLab returns the last-write time of the Strategy file when available. Otherwise, the Strategy's CreationDate is returned.
Gets or sets the serialized Strategy definition.
For a C# Strategy, this contains the Strategy source code. For other Strategy types, it contains the persisted rules or configuration appropriate for that type.
Assigns new default values to the Strategy's optimizable Parameters.
The method updates the appropriate persisted Strategy representation according to StrategyType and assigns the supplied values to the compiled Strategy Parameters.
Returns true if the Strategy can currently be optimized.
The property returns true when PositionSize contains optimizable settings.
Otherwise, the StrategyType must support optimization and the Strategy must contain one or more compiled Strategy Parameters.
Returns a ParameterList containing the Strategy Parameters and any PositionSize Parameters that participate in optimization.
If CompiledStrategy is null, an empty ParameterList is returned.
Restores this Strategy from a string previously created by the legacy Persist method.
The method restores Strategy metadata, StrategyData, DataSet and symbol settings, PositionSize, benchmark, optimization settings, granular processing settings, Preferred Values, external-file linkage, and other persisted state.
For a compiled Strategy, the appropriate compiled Strategy instance is also created.
Creates and returns a Strategy from its XML representation.
The PositionSize's serialized advanced PositionSizer information is restored, and a compiled Strategy instance is created when appropriate.
Returns the Strategy encoded using WealthLab's legacy tokenized persistence format.
The persisted information includes Strategy metadata, StrategyData, backtest settings, PositionSize, symbol and DataSet configuration, optimization settings, Preferred Values, granular processing settings, external-file linkage, and parameter state.
Returns an XML representation of the Strategy.
Before serialization, the current compiled Strategy Parameter values are copied into ParameterValues, and PositionSize prepares any advanced PositionSizer information for XML serialization.