Enums
Namespace: WealthLab.Core
Parent:

These are the various enumerated types used throughout the WealthLab .NET Framework.

Enumerated Types
HistoryScales
public enum HistoryScales

Represents the scale of historical data. Possible values are:

  • Daily
  • Weekly
  • Monthly
  • Quarterly
  • Yearly
  • Tick
  • Second
  • Minute

LineStyles
public enum LineStyles

Describes how lines can be drawn in the various chart rendering methods of UserStrategyBase. Possible values are:

  • Solid
  • Dashed
  • Dotted
  • Thick

OrderType
public enum OrderType

Specifies a type of order submitted to the backtester or broker. Possible values are:

  • Market - executes the order at the bar's open price.

  • Limit - executes the order if the bar's price penetrates below (for long entry or short exit) or above (for short entry or long exit) the order price. If the open price of the bar gaps beyond the limit price, the order is filled at the bar's open price.

  • Stop - executes the order if the bar's price penetrates above (for long entry or short exit) or below (for short entry or long exit) the stop price. If the open price of the bar gaps beyond the stop price, the order is filled at the bar's open price.

  • LimitMove - works like a Limit order, but for entry orders only, the backtester will not execute the order if the price opens beyond the order Price. The Wealth-Lab Quotes & Price Triggers tool also contains logic to suppress the execution of LimitMove price triggers whose first recorded tick is beyond the Price.

  • MarketClose - executes the order at the bar's closing price (see Remarks). To model Strategies that execute orders at the close, based on data from the same bar, you'll need to incorporate some special logic as shown in the example below.

  • FixedPrice - a pseudo order type used in cases for backtest analysis to execute an order at exactly the order price specified, which must be within the range of the bar's OHLC data.

Remarks

  • FixedPrice orders are used for analysis only and cannot be used to generate signals.
  • Wealth-Lab has the ability to place Market On Close (MOC) orders with brokers that support MOC orders. As a rule of thumb MOC orders should be placed at least 10 minutes before the close of the session to participate in the closing price auction. Brokers will reject/cancel MOC orders that are not submitted in time.
  • MarketClose orders should be used for live intraday strategies ONLY IF you actually intend to trade at the market's session close. Since Wealth-Lab's backtester executes MarketClose orders on the following bar regardless of the time scale, an intraday strategy's logic should place this order on the penultimate bar before the regular session close.
  • In practice MarketClose orders can be placed at any time of the day. When Auto-Placed, a MarketClose order will be sent to the broker the number of minutes specifed in the Preferences > Trading.

Example Code Comments

For backtesting purposes, traders often wish to evaluate a bar's closing data and place a MarketClose on the same bar. This kind of strategy cannot be realized in live trading, and it cannot be done in Wealth-Lab without intentionally peeking. The strategy below demonstrates peeking logic in order to create a closing trade on the next bar by analyzing the next bar prematurely. The strategy disables signaling and exits with a "return" on the last chart bar (bars.Count - 1) since it's not able to peek at a non-existent bar in the future.

Example Code
using WealthLab.Backtest;
using WealthLab.Core;
using WealthLab.Indicators;
using System.Drawing;

namespace WealthScript123
{
	public class MarketCloseOnSameBarPeekingStrategy : UserStrategyBase
	{
		//Initialize
		public override void Initialize(BarHistory bars)
		{
			smaShort = SMA.Series(bars.Close, 20);
			smaLong = SMA.Series(bars.Close, 50);
			PlotIndicator(smaShort);
			PlotIndicator(smaLong, Color.Red);
		}

		//Execute
		public override void Execute(BarHistory bars, int idx)
		{
			//because we are looking at tomorrow's bar 
			if (idx == bars.Count - 1)
				return;

			//look at tomorrow's crossovers to place orders at close on that bar
			if (smaShort.CrossesOver(smaLong, idx + 1))
				PlaceTrade(bars, TransactionType.Buy, OrderType.MarketClose);
			else if (smaShort.CrossesUnder(smaLong, idx + 1))
				PlaceTrade(bars, TransactionType.Sell, OrderType.MarketClose);
		}

		//private members
		private SMA smaShort;
		private SMA smaLong;
	}
}

ParameterTypes
public enum ParameterTypes

Represents the type of a parameter for a Strategy or Indicator. Parameters are instances of the Parameter class. Possible values are:

  • Int32
  • Double
  • String
  • Boolean
  • TimeSeries
  • BarHistory
  • Color
  • LineStyle
  • Text - a string that exposed as a multiline text field in the user interface
  • Font
  • StringChoice - a string with a discrete number of possible values
  • Indicator
  • Smoother - an indicator that is also a Smoother
  • IndicatorSource - used behind the scenes to flag a parameter to use a source based on another indicator
  • PriceComponent - open, high, low, close, volume, or one of the calculated average prices (PriceComponents enum)
  • Date - .NET DateTime

PeakTroughReversalTypes
public enum PeakTroughReversalTypes

Describes the method that a PeakTroughCalculator used to determine peak/trough reversals. Possible values are:

  • Percent
  • Point

PeakTroughTypes
public enum PeakTroughTypes

Specifies whether an instance of the PeakTrough class represents a peak or a trough. PeakTrough instances are generated by the PeakTroughCalculator utility class. Possible values are:

  • Peak
  • Trough

PlotStyles
public enum PlotStyles

Represents the various types of indicator plotting styles available. Possible values are:

  • Line
  • Histogram
  • Dots
  • ThickLine
  • ThickHistogram
  • DottedLine
  • DashedLine
  • BooleanDots - always plots in the price pane, and draws a dot above the price bar whenever the indicator value is greater than zero. Bands - renders filled bands based on the source indicator and its BandCompanion - if a BandCompanion could not be found, plots as a line. ZigZag - works best with indicators like ZigZag which are composed of sporadic values interspersed with Double.NaN. Draws lines between the non-NaN values. Blocks - plots outlined blocks, each block encompasses a range of values that are the same. Useful for fundamental data. GradientBlocks - Like Blocks above, but fills the blocks with a gradient.

PositionType
public enum PositionType

Specifies the type of position, long or short. Possible values are:

  • Long
  • Short

PriceComponents
public enum PriceComponents

Represent the components of historical data, and some components derived from averaging the base components. Possible values are:

  • Open
  • High
  • Low
  • Close
  • Volume
  • AveragePriceOHLC
  • AveragePriceHLC
  • AveragePriceHL
  • AveragePriceOC
  • AveragePriceHLCC

SignalStatuses
public enum SignalStatuses

Represents the possible states of an order during its lifetime interacting with a broker. Possible values are:

  • Staged
  • Placed
  • Active
  • Filled
  • PartialFilled
  • CancelPending
  • Canceled
  • Error

StrategyExecutionModes
public enum StrategyExecutionModes

Represents the mode in which the backtester is operating and can be accessed through the backtester ExecutionMode property. Possible values are:

  • Strategy: running a standard Strategy Window backtest
  • Optimization: performing an optimization
  • StreamingChart: This value is returned if a strategy was dropped into a chart window. Streaming may or may not be enabled.
  • StrategyMonitor: operating in the Strategy Monitor
Example Code
using WealthLab.Backtest;
using System;
using WealthLab.Core;
using WealthLab.Indicators;
using System.Drawing;
using System.Collections.Generic;

namespace WealthScript1
{
	public class MyStrategy : UserStrategyBase
	{
		public override void Initialize(BarHistory bars)
		{			
			DrawHeaderText(ExecutionMode.ToString(), Color.Blue, 16);

			switch (ExecutionMode)
			{
				case StrategyExecutionModes.Optimization:
					_isOptimization = true;
					break;
				case StrategyExecutionModes.Strategy:
					_isStrategyWindow = true;
					break;
				case StrategyExecutionModes.StrategyMonitor:
					_isStrategyMonitor = true;
					break;
				case StrategyExecutionModes.StreamingChart:
					_isStreaming = true;
					break;
				default:
					break;
			}
		}

		//execute the strategy rules here, this is executed once for each bar in the backtest history
		public override void Execute(BarHistory bars, int idx)
		{


		}

		bool _isStreaming;
		bool _isOptimization;
		bool _isStrategyWindow;
		bool _isStrategyMonitor;
	}
}

TrailingStopTypes
public enum TrailingStopTypes

Trailing stop orders can be created using the CloseAtTrailingStop method of UserStrategyBase. The values below determine how trailing stop values are calculated.

  • PercentC - based on a percentage above/below price, calculated using closing price.
  • PercentHL - based on a percentage above/below price, calculated using highs and lows.
  • PointC - based on a fixed amount above/below price, calculated using closing price.
  • PointHL - based on a fixed amount above/below price, calculated using highs and lows.
  • ATR - based on a variable amount above/below price, calculated using highs and lows. For the Chandelier exit, the distance from the highest/lowest point to the trailing stop is measured in units of 22-period Average True Range.

TransactionType
public enum TransactionType

Specifies the type of transaction (or order). Possible values are:

  • Buy
  • Sell
  • Short
  • Cover