The Backtester class executes WealthLab 9 backtests and provides access to the resulting positions, transactions, equity curves, performance metrics, and other simulation information. The Backtester instance for a running C# Strategy is available through the Backtester property of UserStrategyBase. The Backtester contains the underlying trading methods used by UserStrategyBase. Strategy code will normally call the equivalent UserStrategyBase methods directly.
The BacktestSettings class contains the settings and preferences that control how WealthLab 9 conducts a backtest, including commissions, slippage, interest, dividends, futures handling, position matching, signal ordering, and multi-currency simulation.
The BarData class represents a single bar of market data, including open, high, low, close, volume, bid, ask, symbol, timestamp, and source information.
The BarGlyphBase class is the base class for small chart glyphs that appear above or below individual bars. BarGlyphs are commonly used to visually represent events such as dividends, splits, earnings, or chart patterns. BarGlyphBase derives from PlotBase, so it also inherits PlotBase's chart access, configuration, coordinate conversion, and rendering functionality.
The BarHistory class represents historical price and volume data for a market. Code-based Strategies receive a BarHistory instance in Initialize, Execute, and other Strategy methods. A bar contains open, high, low, close, and volume values. BarHistory exposes these through the Open, High, Low, Close, and Volume properties, each of which is a TimeSeries synchronized with the inherited DateTimes collection.
BarHistoryCompressor is a static utility class containing methods that compress a BarHistory from a more granular scale to a less granular scale. For example, you can use ToWeekly to compress a daily BarHistory into weekly bars. Compression preserves the first Open, highest High, lowest Low, last Close, and sums Volume for each resulting bar. Named TimeSeries registered with the source BarHistory are also carried into the compressed BarHistory. If you want to use data calculated from a compressed BarHistory on a chart or Strategy running at the original scale, synchronize the resulting TimeSeries back to the original scale using TimeSeriesSynchronizer.
BarHistorySynchronizer is a static utility class containing the Synchronize method, which synchronizes a BarHistory to the DateTimes of another TimeSeriesBase. The master can be either a TimeSeries or another BarHistory because both derive from TimeSeriesBase. This is useful when data has been compressed or otherwise exists at a different scale than the Strategy or chart. For example, you can compress daily data to weekly bars and then synchronize the weekly BarHistory back to the original daily BarHistory for plotting. When the source and master use different markets, BarHistorySynchronizer also accounts for market time-zone differences for intraday data.
This Deep Learning utility class accepts Model training Inputs and Outputs and returns batches of data according to the specified batch size. The batching operation occurs in the class constructors.
The BrokerAccount class represents an account associated with a connected Broker Provider. It contains account balances, Broker-reported Positions, currency balances, Portfolio Sync Live Positions, Strategy Positions, and other account-specific information.
The ChartPreferences class contains the visual settings used to render a WealthLab chart, including its colors, Chart Style, bar spacing, panes, cursors, event icons, trade arrows, fonts, and other display options.
The ChartTooltip class contains the text and color information used to render a tooltip on a WealthLab chart. It is primarily used by chart elements such as BarGlyphs when displaying mouse-over information.
The ChildWindow class derives from WPF UserControl and provides the integration points required for a custom window to participate in WealthLab 9's multiple document interface. Client Extensions typically derive their custom windows from ChildWindow so WealthLab can manage activation, workspace persistence, chart integration, editor integration, Expert Mode, and window lifecycle events.
The Configurable class provides base functionality for WealthLab components that support configuration. Configurable implements the IParameterized and INamed interfaces. Configuration can be represented either as a plain string or as a persisted ParameterList, as determined by the ConfigurableType property. The Configurable constructor calls GenerateParameters and then LoadConfig, so derived classes can define their Parameters and automatically restore previously saved configuration when they are instantiated.
The CustomSettingsPanel class allows Historical Data Provider extension authors to define their own configuration user interface for their Provider in the Data Manager.
The DataPanelItem class contains the information displayed in a row of the WL9 Data Panel. If you are building a Data Panel ScoreCard Extension, create DataPanelItem instances and add them to the List returned by its GetItems method.
The DataSet class represents a DataSet in WL9, either created by the user using the New DataSet Wizard, or generated by a DataSet Provider. DataSet Providers can return instances of classes derived from DataSet, allowing them to customize behavior such as symbol membership, historical data retrieval, and supported scales. DataSet implements the IHistoryProvider and INamed interfaces.
The DateRange class represents a range of date/time values. It can optionally be associated with a symbol through the Symbol property.
DateSynchedList
DateTime extension methods provide utility functions for working with dates and times, particularly for trading calendars, option expiration dates, date formatting, and time-based strategy logic. Call these methods directly on a DateTime instance using standard extension method syntax.
Represents a component line in a chart drawing object. A DrawingObjectLine is defined by two Handle instances and provides properties that control its appearance, visibility, extension, and interaction behavior.
This page documents enumerated types used throughout the WealthLab .NET Framework.
The EventDataCollection class contains a collection of EventDataPoint instances associated with a symbol. Event Data Providers use EventDataCollection instances when working with event data that has been read from persistent storage.
The EventDataPoint class represents a single piece of event data, such as a fundamental data item (dividend, split, earnings), analyst rating, or chart pattern. WealthLab supports several Event Data Providers, both included out of the box and available via extensions. Each provider supplies its own set of historical event data. You can access event data using the EventDataPoints property or the GetEventDataPoints method of the BarHistory class.
The Handle class represents a draggable handle belonging to a chart drawing object. Handles define points used by DrawingObjectBase-derived objects and can typically be moved by the user with the mouse.
The HeikinAshi static class converts a BarHistory into a Heikin-Ashi representation. It supports both standard Heikin-Ashi calculations and an alternate smoothed version that first smooths the source OHLC series using a specified Indicator.
The HistoricalDataPoint class represents a point of historical data on a WealthLab chart. It implements the IChartPoint interface and contains an x-axis bar index and a y-axis value.
The HistoryScale class represents a historical data scale, such as daily, weekly, monthly, or a 5-minute intraday scale. It implements the IComparable interface, allowing HistoryScale instances to be compared according to their relative granularity.
The HolidaySet class represents a named collection of market holiday dates and special market hours. HolidaySet instances are used by MarketManager and MarketDetails to define market-specific holiday schedules.
The IBulkUpdateHost interface is used by Historical Data Providers to communicate with WL9 during a Provider Update. It provides methods for writing messages to the update log and notifying WL9 when the update has completed.
The IChart interface allows WL9 to communicate with a chart contained in a ChildWindow. The WealthLab.WPF Chart class implements IChart. If you are implementing a ChildWindow in a WealthLab extension that contains a chart, override the ChildWindow Chart property to return an instance of this interface.
The ICustomSettingsEditor interface is implemented by custom editor panels that edit the configuration of a Configurable object that uses ConfigurableType.VanillaString. It provides access to the configuration string being edited and to the host that manages the editing session.
The ICustomSettingsHost interface allows a custom settings editor to communicate configuration changes back to the WL9 user interface.
The IHost interface represents the WL9 host environment and provides key integration points for Strategies and WL9 Extensions. You can access the singleton instance of IHost through WLHost.Instance.
The IMetricsReportHost interface is used by ScoreCard extensions to define the layout of their performance metrics reports. An instance of this interface is passed to the ScoreCard's LayoutMetricsReport method, where you can add metric values, headers, and separators to the report.
The INamed interface is implemented by objects that expose a name.
IndicatorBase is the base class for technical indicators in WealthLab. It derives from TimeSeries and implements the INamed interface. In addition to the DateTimes and Values inherited from TimeSeries, IndicatorBase provides the metadata, parameters, plotting information, companion indicators, and calculation methods used by the WealthLab indicator subsystem. Developers creating custom indicators derive their classes from IndicatorBase and implement the required descriptive properties, parameters, and calculation logic.
The IOptimizationHost interface allows Optimization Visualizers to communicate with their host Optimization (Strategy) window. It provides access to the Optimizers used during an optimization and methods for running WFO backtests, displaying detailed results, and communicating optimization results between Visualizers.
The IOptimizerHost interface allows Optimizers, classes derived from OptimizerBase, to communicate with their host Optimization window. It provides access to the Strategy, benchmark results, selected performance metrics, and optimizable Parameters, and allows the Optimizer to report progress and Walk-Forward Optimization (WFO) interval changes.
The IParameterEditor interface represents a parameter editor that displays and edits a ParameterList. It provides methods that allow an IParameterized object to interact with the editor when a Parameter is changed, including retrieving Parameter values, changing label text, and enabling or disabling controls.
The IParameterized interface is implemented by objects that contain Parameters that can be changed in a parameter editor. It provides a hook that allows the object to respond when one of its Parameters is edited and to interact with the parameter editor.
The IStrategyHost interface allows Performance Visualizers and other components to communicate with their host Strategy window. It provides access to the Strategy and its Backtester instances, methods for navigating and charting results, running the Strategy with Parameter overrides, and information about the selected Broker and account.
The IStreamingBarConsumer interface allows a consumer of streaming bar data to receive completed or updated bars from a Streaming Data Provider.
The IStreamingConsumer interface allows a consumer of streaming market data to receive price, size, bid/ask, and heartbeat updates from a Streaming Data Provider.
The IWLClientHost interface provides properties and methods that allow ChildWindow instances, charts, and client extensions to communicate with the main WL9 window. It provides access to navigation, Strategy windows, chart coordination, streaming, theming, sounds, extension services, and other features of the WL9 user interface. The primary IWLClientHost instance is also available through WLClientHost.Instance.
LineUtils is a static utility class containing methods for projecting trendlines and constructing parallel, channel, and triangle trendlines.
The ManuallyDrawnObject class represents a drawing object, such as a trend line, Fibonacci retracement, or text note, that was manually placed on a WL9 chart. WL9 associates manually drawn chart objects with a symbol and HistoryScale.
The MarketDetails class contains information about a financial market, such as the US stock market, futures markets, or cryptocurrency markets. It defines properties such as trading days, market hours, time zone, holidays, security type, currency, and display conventions. Historical Data Providers can create MarketDetails instances and associate them with symbols. Users can also create and modify markets using the Markets & Symbols tool.
MarketDetailsUsaStocks is a specialized MarketDetails class that represents the US stock market. It defines the standard US stock market trading hours, Eastern time zone, weekday trading schedule, holiday calendar, benchmark symbol, and other market-specific information.
The MarketHours class represents the open and close times of a market, and is used to represent market trading hours in the MarketDetails class.
MarketManager is a static utility class that manages information about markets and symbols in WealthLab. It maintains a collection of MarketDetails instances representing markets such as US stocks, futures, Forex, and cryptocurrencies, as well as SymbolInfo instances containing symbol-specific information. MarketManager is particularly useful to developers of custom Data Provider extensions that need to install or access market and symbol information.
The MarketWeeklyHours class represents the trading hours for each day of a market's week. It maintains a collection of MarketHours instances keyed by day of week, with an optional default entry that applies when a specific day does not have its own hours defined. A key value of -1 represents the default market hours.
The OptimizationResult class contains the results of a single optimization run, including the Parameter values used, calculated performance metrics, run information, and any error that occurred during the run.
OptimizationResultList is a List of OptimizationResult instances that provides helper methods for locating results, filtering results, and persisting or restoring the list.
OptimizationRunnerBase is the base class for objects that conduct optimizations in WL9. It provides common access to the historical data, compiled Strategy, Optimizer, Position Size, Backtest Settings, host interface, and optimizable Parameters used during an optimization.
OptionChain organizes the option expirations and strikes available for a single underlying symbol. Each expiration is represented by an OptionSymExp instance, which contains the option symbol root and available strikes for that expiration.
The OptionGreek class contains a set of option Greeks, implied volatility values, prices, and related market data for a single option symbol. Historical Data Providers that support options can populate and return OptionGreek instances. Not every Provider necessarily populates every field.
OptionsHelper is a static utility class that provides methods for recognizing, parsing, building, and converting option symbols in the formats used by WealthLab and various data and brokerage Providers. It also provides a method for estimating the underlying price corresponding to a specified option delta.
The OptionSymExp class represents the available strikes for a particular option expiration. OptionSymExp instances are typically added to an OptionChain to construct a complete option chain.
OptionSynthetic is a static utility class that generates synthetic option symbols and calculated option price histories. It also provides methods for calculating option prices and Greeks using the Black-Scholes model. Synthetic option calculations require an estimate of implied volatility (IV). The resulting prices and Greeks will only approximate actual option values to the extent that the supplied IV accurately represents the option's implied volatility. OptionSynthetic is particularly useful when developing and backtesting option trading strategies when historical option contracts or option chains are not available.
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.
The ParameterList class descends from List<Parameter> and contains Parameter instances. Various classes in the WealthLab code base expose a ParameterList as their Parameters property, including IndicatorBase, OptimizerBase, DrawingObjectBase, and many of the data provider base classes.
The PeakTrough class represents a peak or trough detected in time series data by the PeakTroughCalculator utility class. It implements the IChartPoint interface, so its XIndex and YValue properties can be used wherever chart points are accepted.
The PeakTroughCalculator class calculates peaks and troughs in source time series data. Peaks and troughs are detected when the data reverses by a specified amount, which can be expressed as a percentage, point value, ATR multiple, or ATR percentage. The resulting PeakTrough instances are available through the PeakTroughs property. Because a reversal must occur before a peak or trough can be confirmed, detection always occurs after the actual peak or trough. Each PeakTrough contains both the index where the peak or trough occurred (PeakTroughIndex) and the index where it was confirmed (DetectedAtIndex).
The PenBrushFactory class is a static utility that creates and caches WPF Pen and Brush objects. It also exposes colors and brushes derived from the currently selected WL9 Theme. Repeated requests for the same WLColor-based Brush or the same Pen definition reuse cached objects instead of creating new instances.
PlotBase is the base class for objects that can be plotted on a WL9 chart. It provides access to the chart, pane, historical data, chart preferences, coordinate conversion, rendering passes, configuration, and a number of helper methods for rendering lines, rectangles, and text.
The Position class represents a long or short position generated by the WealthLab backtester. A long Position results from a buy transaction, while a short Position results from a short transaction. A Position contains information about its entry and exit, quantity, profit and loss, commissions, excursions, position metrics, currency conversion, and other details associated with the simulated or live position.
PositionList is a List<Position> with additional utility properties for summarizing position performance and a method for generating an equity curve from the Positions it contains.
Represents the position sizing settings established for a backtest. PositionSize defines the sizing method and amount, starting capital, margin factor, maximum open positions, maximum entry signals per bar, and optional advanced PositionSizer. It also contains the settings used when optimizing position sizing parameters.
PriceGrid maps a section of price or TimeSeries data into a two-dimensional grid that can be used for pattern comparison.
Each grid cell contains either '.', representing an empty cell, or 'X', representing price data. PriceGrid instances can be compared to determine how closely one price pattern resembles another.
public string Persist()
Derived from WPF UserControl, ResultViewerBase serves as the base class for WL9 Strategy and Optimization result viewers. It provides lifecycle hooks, tab presentation properties, and helper methods for configuring TeeChart controls and creating commonly used TeeChart series. public virtual void Initialize()
Contains the information saved from a WealthLab optimization run, including the Strategy, Optimizer, position sizing, backtest settings, optimization parameters, and generated results. SavedOptimizationResults supports standard, Walk-Forward Optimization (WFO), and Symbol-by-Symbol optimization runs.
SettingsManager manages a collection of string-keyed settings and persists them to a local file. It supports several common data types, optional file encryption, throttled disk writes, and thread-safe access through internal locking.
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.
A List of StrategyEvolverResult instances with helper members for locating the best result and examining performance metrics by generation. The list can contain results from multiple generations, including both Strategies that passed the Evolver Filter and those that were filtered out.
Executes optimization runs for Optimizers. Optimizer extensions call the ExecuteOptimizationRun method to execute individual optimization runs, and Optimization Visualizers access the Results to represent optimization performance results.
A helper class that provides a simplified way to run Strategy backtests and optimizations programmatically. StrategyRunner can be used from a WealthLab Extension or directly from Strategy code.
Before running a backtest or optimization, configure its data source, scale, data range, position sizing, backtest settings, and benchmark as required.
StrategyRunner implements IOptimizationHost and IOptimizerHost so that it can host and execute a StrategyOptimizer programmatically.
The SymbolInfo class represents information about a single tradable instrument, identified by its Symbol property. SymbolInfo contains information such as the symbol's market, security type, currency, price precision, quantity precision, futures point value, margin, and tick size. SymbolInfo instances can be created by Historical Data Providers, and users can define or edit symbol information in WealthLab's Markets & Symbols tool. When Futures Mode is enabled in WealthLab's Backtest Settings, properties such as Margin, PointValue, and TickSize are used when calculating backtest results for compatible security types.
The Synchronizer class provides synchronized, iterative access across multiple TimeSeriesBase instances. It is useful when you need to process several TimeSeries or BarHistory objects in chronological order even when they do not all contain data for the same DateTimes. Each call to Next advances the Synchronizer to the earliest remaining DateTime among all of the supplied series and returns the TimeSeriesBase instances that contain data at that DateTime.
TabPage is a user interface class derived from the WPF UserControl. It serves as the base class for custom pages that WL9 Extensions can add to the WL9 Preferences tool.
A custom WL9 Extension (WL9ExtensionBase) can override its PreferencePages property to return TabPage instances. WealthLab adds these pages to the Preferences tool's tab control.
Override the properties and methods below to provide the tab's text and help page, perform initialization and cleanup, and respond to changes in Expert Mode.
The Tick class represents a tick, or single trade, in a market data stream. It contains the trade's price, size, and timestamp. Tick is serializable and provides methods for persisting and restoring its values.
The TimeSeries class manages a series of numeric double values keyed to a list of DateTimes. The two primary properties of TimeSeries are:
TimeSeriesBase is the common base class used by TimeSeries and BarHistory. It provides shared functionality for working with data synchronized to a List of DateTimes. Two important concrete classes derive from TimeSeriesBase:
TimeSeriesCompressor is a static utility class containing methods that compress a TimeSeries from one scale into a less granular scale. For example, you can use ToWeekly to compress a daily TimeSeries into a weekly TimeSeries. For each compressed period, TimeSeriesCompressor retains the last value from the source TimeSeries. This makes it suitable for compressing series such as closing prices or calculated indicators. If you need the true open, high, or low of a compressed period, use BarHistoryCompressor instead. If you want to plot or otherwise use a compressed TimeSeries alongside its original-scale data, use TimeSeriesSynchronizer to expand the compressed series back to the original DateTimes.
TimeSeriesSynchronizer is a static utility class used to synchronize a TimeSeries with the DateTimes of another TimeSeriesBase instance. The master series can be either a TimeSeries or a BarHistory. The returned TimeSeries contains the same DateTimes as the master, with values from the source carried forward as appropriate. This is especially useful when working with indicators or TimeSeries calculated at a different scale. For example, you can compress daily data to weekly, calculate an indicator on the weekly series, and then synchronize the result back to the original daily BarHistory for plotting or use in Strategy logic.
The Transaction class represents a trading order or signal generated during a backtest or processed by WealthLab's trading infrastructure. When developing a C# Strategy, methods such as PlaceTrade return a Transaction instance. You can modify selected properties of the Transaction, such as Quantity, Weight, Tag, AutoStopLossPrice, or AutoProfitTargetPrice, to customize the resulting order. A Transaction also contains information about backtest execution, live broker status, fills, signal origin, account information, and the Position that can result from the order.
The TrendLine class represents a line defined by two index/value coordinates. TrendLine instances are commonly generated by PeakTroughCalculator methods such as GetLowerTrendLine and GetUpperTrendLine, but you can also create one directly from two arbitrary points. When constructed from a collection of PeakTrough instances, the TrendLine represents the best-fit linear regression line through those points rather than simply connecting the first and last PeakTrough.
UserStrategyBase represents a trading Strategy in WealthLab 9. When you work with C# Code-Based Strategies, you are actually coding a custom class that is derived from UserStrategyBase. The class provides properties and methods that let you control the logic of the trading system, including placing orders and examining the current state of the system. You hook into the trading system logic by overriding several virtual methods in UserStrategyBase. These methods pass as a parameter the instance of the BarHistory object that contains the historical data to backtest. The following are the most important methods:
The VolumeProfile class calculates a Volume Profile for a BarHistory over a specified lookback period. The profile divides the recent price range into a series of horizontal price bins represented by VolumeProfileItem instances. Each historical bar's volume is distributed across every profile bin intersected by that bar's High/Low range. The resulting profile can be used to identify the Point of Control, Value Area, and low-volume nodes above and below the Point of Control. For each source bar, WealthLab determines every profile price bin intersected by the bar's High/Low range. The bar's volume is divided equally among those bins. For example, if a bar contains volume of 100,000 and its price range overlaps four VolumeProfileItem bins, each bin receives 25,000 volume. The volume is added to either UpVolume or DownVolume depending on whether that source bar closed at or above the previous bar's Close. After volume has been distributed, WealthLab identifies the VolumeProfileItem with the greatest TotalVolume as the Point of Control. It then begins at the Point of Control and expands outward, adding neighboring profile bins to the Value Area until approximately ValueRangePct percent of total profile volume has been included. Finally, the relative width values of every VolumeProfileItem are calculated against the Point of Control's volume:
The VolumeProfileItem class represents a single horizontal price bin in a Volume Profile. The VolumeProfile.Items collection contains the VolumeProfileItem instances generated for a Volume Profile. Each item represents a specific price range and contains the up volume, down volume, Value Area status, Point of Control status, and relative display widths associated with that range.
The WFOOptimizer class performs Walk-Forward Optimization (WFO). A WFO divides the available historical data into a sequence of in-sample and out-of-sample intervals. For each interval, WealthLab optimizes the Strategy using the in-sample period, selects the best parameter set using a WFOResultSelectorBase, and then applies those parameters to the corresponding out-of-sample period. WFOOptimizer collects the resulting WFOResult instances for use by Walk-Forward Optimization Visualizers and other extension code. WFOOptimizer implements IOptimizerHost because each in-sample interval is executed internally by a StrategyOptimizer.
The WFOResult class extends OptimizationResult with information specific to a single Walk-Forward Optimization interval. A WFOResult can represent either the in-sample optimization result or the corresponding out-of-sample result for an interval. It also stores the date ranges, WFO Efficiency, selected parameter values and performance metrics inherited from OptimizationResult, and optional details about the complete in-sample optimization. WFOResult is also used to represent the optional Pre-Live WFO run.
The WLColor class represents a color in a platform-independent way. A WLColor consists of alpha, red, green, and blue components, each represented by a byte from 0 to 255. WealthLab uses WLColor throughout its API wherever a color needs to be specified without depending on a platform-specific color implementation. The original WLColor is not modified. WLColor provides static properties for a comprehensive set of standard named colors. For example:
The WLFont class represents a font in a platform-independent way. It stores the font family name, size, and bold and italic attributes used by WealthLab for chart labels and other visual elements.