Clone our Wealth-Lab 8 Extension Demo project on GitHub to get a head start in developing your own Extensions!

Optimization Visualizer API

An Optimization Visualizer Extension adds a custom tab to the Optimization Results section of the Strategy window in WealthLab 9. Optimization Visualizers let you present optimization results in specialized ways, such as tables, charts, heat maps, parameter analysis, or other visual representations.

Build Environment

You can create an Optimization Visualizer in a .NET development tool such as Visual Studio 2026. Create a class library project that targets .NET10, then reference the WealthLab.WPF library DLL that you'll find in the WL9 installation folder.

Your Optimization Visualizer will be a class in this library that descends from OptimizationVisualizerBase, which is defined in the WealthLab.WPF library, in the WealthLab.WPF namespace. After you implement and build your library, simply copy the resulting assembly DLL into the WL9 installation folder. The next time WL9 starts up, it will discover your Optimization Visualizer, making it available in appropriate locations of the WL9 user interface.

Visual Studio 2026 Build Environment

Accessing the Host (WL9) Environment

The IHost interface provides access to the current WealthLab environment. Extensions can use it to retrieve application-level information and services, such as the location of the user's WealthLab data folder or the DataSets defined by the user.

You can access the current IHost instance from anywhere in your extension through the WLHost singleton and its Instance property. For example, the following code retrieves the path to the user's WealthLab data folder:

string folder = WLHost.Instance.DataFolder;

Use WLHost.Instance whenever your extension needs access to functionality exposed by the IHost interface.

ResultViewerBase

OptimizationVisualizerBase derives from ResultViewerBase, which is defined in WealthLab.WPF. ResultViewerBase ultimately derives from WPF's UserControl and provides functionality shared by WealthLab result viewers. Two important descriptive properties inherited from ResultViewerBase are:

  • ViewerName - Controls the text displayed on the Visualizer's tab.
  • GlyphResource - Controls the icon displayed on the Visualizer's tab.

Creating an Optimization Visualizer in Visual Studio

A convenient way to begin is to create a new WPF UserControl in Visual Studio. This creates the initial XAML and C# files for the Visualizer. Next, modify the C# class so it derives from OptimizationVisualizerBase instead of UserControl. Add the WealthLab.WPF namespace:

using WealthLab.WPF;

Then update the XAML file to include an XML namespace reference for WealthLab.WPF and change the root element from UserControl to OptimizationVisualizerBase. For example, the root element will follow this general pattern:

<wl:OptimizationVisualizerBase
    x:Class="MyExtension.MyOptimizationVisualizer"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:wl="clr-namespace:WealthLab.WPF;assembly=WealthLab.WPF">

    <!-- Visualizer UI -->

</wl:OptimizationVisualizerBase>

Optimization Type

public virtual bool ForStandardOptimizations

Determines whether the Visualizer is intended for standard optimizations or Walk-Forward Optimizations. Return:

  • true for standard optimizations.
  • false for Walk-Forward Optimizations.

Common Optimization Information

Clear

public virtual void Clear()

WealthLab calls Clear when a new optimization begins. Override this method to remove results, controls, charts, or other visual information left over from a previous optimization.

MetricNames

public List<string> MetricNames

Returns the performance metrics selected by the user when the optimization began. These correspond to the metrics contained in the OptimizationResult instances produced by the optimization. Use this collection when your Visualizer needs to determine which performance metrics are available for display or analysis.

OptimizationMethod

public OptimizerBase OptimizationMethod

Returns the OptimizerBase instance representing the optimization method selected by the user. This gives the Visualizer access to information specific to the Optimizer that produced the results.

Visualizing Standard Optimizations

Populate

public virtual void Populate(
    StrategyOptimizer stratOpt)

WealthLab calls Populate when a standard optimization has completed. The supplied StrategyOptimizer contains the information required to visualize the optimization. Most importantly, its Results property contains an OptimizationResultList, which derives from:

List<OptimizationResult>

Each OptimizationResult represents one optimization run and contains its parameter values and performance results. A typical Visualizer will enumerate these results and build its display from them.

For example:

public override void Populate(
    StrategyOptimizer stratOpt)
{
    foreach (OptimizationResult result
        in stratOpt.Results)
    {
        // Process the optimization run.
    }
}

StrategyOptimizer

public StrategyOptimizer StrategyOptimizer

Returns the StrategyOptimizer instance associated with the current standard optimization.

Interim Updates

public virtual bool SupportsInterimUpdates

Return true if your Visualizer can display results while an optimization is still running. When enabled, WealthLab periodically supplies newly completed optimization results through InterimPopulate.

public virtual void InterimPopulate(
    StrategyOptimizer stratOpt,
    List<OptimizationResult> newResults)

WealthLab calls this method when new optimization runs become available and SupportsInterimUpdates returns true. The newResults collection contains only the newly completed OptimizationResult instances. Use these results to update the existing visualization without rebuilding it from scratch.

PopulateWithTheseValues

public virtual void PopulateWithTheseValues(
    OptimizationResult or)

Some Optimization Visualizers allow the user to select a particular optimization run and propagate that selection to other Visualizers. WealthLab calls PopulateWithTheseValues when this occurs. Override this method when your Visualizer should update its display to reflect the parameter values or results contained in the supplied OptimizationResult.

Visualizing Walk-Forward Optimizations

PopulateWFO

public virtual void PopulateWFO(
    WFOOptimizer wfoOpt)

WealthLab calls PopulateWFO when a Walk-Forward Optimization has completed. The supplied WFOOptimizer contains the information required to visualize the Walk-Forward results. Override this method for Visualizers whose ForStandardOptimizations property returns false.

WFOOptimizer

public WFOOptimizer WFOOptimizer

Returns the WFOOptimizer instance associated with the current Walk-Forward Optimization.

Interacting with the Strategy Window

ParentOptimizationWindow

public IOptimizationHost ParentOptimizationWindow

Returns the IOptimizationHost representing the Optimization section of the Strategy window that contains the Visualizer. Use this interface when your Visualizer needs to interact with the surrounding optimization environment. The IOptimizationHost also exposes a StrategyHost property, which returns an IStrategyHost and provides additional access to the containing Strategy window.

SaveParameterDefaults

protected void SaveParameterDefaults(
    OptimizationResult or,
    FrameworkElement confirmElement = null)

Call this method to set the Strategy's default Parameter values to those contained in the specified OptimizationResult. This is useful when the user identifies an optimization run they want to use as the Strategy's new default configuration. For example:

SaveParameterDefaults(selectedResult);

You can optionally pass a WPF FrameworkElement in confirmElement:

SaveParameterDefaults(
    selectedResult,
    myButton);

When supplied, WealthLab displays an animated confirmation over that element after the Parameter defaults are saved. One example of this behavior is the Tabular Optimization Visualizer, where the user can right-click an optimization run and set its Parameter values as the Strategy defaults.