Search Framework:
Enums
Namespace: WealthLab.Core
Parent:

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

Enumerated Types
Frequency
public enum Frequency

Represents the frequency of historical data. Possible values are:

  • Daily
  • Weekly
  • Monthly
  • Quarterly
  • Yearly
  • Tick
  • Second
  • Minute
  • Volume
  • Hour
  • NDays
  • WeeklyStartDay

LineStyle
public enum LineStyle

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

  • Solid
  • Dashed
  • Dotted

OptimizationRunType
public enum OptimizationRunType

Possible values are:

  • None
  • Standard
  • WFO
  • SymbolBySymbol

OrderType
public enum OrderType

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

  • Market
  • Limit
  • Stop
  • FixedPrice
  • LimitMove
  • MarketClose
  • LimitClose
  • StopLimit

Remarks

  • Limit - executes the simulated 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 simulated order is filled at the bar's open price.
  • Stop - executes the simulated 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 simulated order is filled at the bar's open price.
  • StopLimit - works like a Stop order with a Limit price fill constraint. Assign the limit price to the Transaction's StopLimitLimit property (see example). A Limit price can be on either side of the Stop price, although some brokers may not accept a StopLimit order whose Limit price is not beyond the Stop price.
  • LimitMove - works like a Limit order, but for entry orders only, the backtester will not execute the simulated 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 simulated 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.
  • LimitClose - like MarketClose with a Limit price constraint. If the settled close is not "at or better" than the limit price, the order is not filled.
  • FixedPrice - a pseudo order type used in cases for backtest analysis to execute an order at exactly the order price specified, which should be within the range of the bar's OHLC data.

Market-On-Close, Limit-On-Close Usage Notes

  1. Wealth-Lab can place Market On Close (MOC) and Limit On Close (LOC) orders with brokers that support them. As a rule of thumb "On Close" 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 "On Close" orders that are not submitted in time.
  2. Wealth-Lab's backtester executes MarketClose and LimitClose orders on the following bar regardless of the time scale. An intraday strategy using On-Close orders should place this order on the penultimate bar before the regular session close.
  3. Intraday strategies should not use On-Close orders except for closing session logic. Regular Market and Limit orders should be used for midday trading.
  4. Market/LimitOnClose orders can be placed at any time of the day. For more information on MarketClose and LimitClose live trading behaviors, see Preferences > Trading > Special Order Types > Use MOC/LOC when Possible.

Example Code Comments

For hypothetical backtesting, traders often wish to evaluate a bar's closing data and place a MarketClose on that 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 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 WealthScript1 
{
	public class MarketClosePeekingExitStrategy : UserStrategyBase
	{
		//Initialize
		public override void Initialize(BarHistory bars)
		{
			smaShort = SMA.Series(bars.Close, 20);
			smaLong = SMA.Series(bars.Close, 50);
			PlotIndicator(smaShort, WLColor.Gold);
			PlotIndicator(smaLong, WLColor.Red);
			PlotStopsAndLimits(3);
		}

		//Execute
		public override void Execute(BarHistory bars, int idx)
		{
			if (!HasOpenPosition(bars, PositionType.Long))
			{
				//Buy using a StopLimit order when price attains the short sma
				if (bars.Close[idx] < smaShort[idx] && bars.Close[idx] < smaLong[idx])
				{
					Transaction t = PlaceTrade(bars, TransactionType.Buy, OrderType.StopLimit, smaShort[idx], "StpLmt");
					t.StopLimitLimitPrice = smaShort[idx] * 1.005;
				}
			}
			else
			{
				if (idx == bars.Count - 1)
					return;
				
				//look at tomorrow's crossover to place order at close on that bar
				//exit with the short sma crosses above the slow sma
				if (smaShort.CrossesOver(smaLong, idx + 1))
					PlaceTrade(bars, TransactionType.Sell, OrderType.MarketClose);
			}
		}

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

ParameterType
public enum ParameterType

Represents the type of a parameter for a Strategy or Indicator. (Strategies only support Int32 and Double type parameters.) Parameters are instances of the Parameter class. Possible values are:

  • Int32
  • Double
  • String
  • Boolean
  • TimeSeries
  • BarHistory
  • Color
  • LineStyle
  • Text
  • Font
  • StringChoice
  • Indicator
  • Smoother
  • IndicatorSource
  • PriceComponent
  • DataSet
  • ColorWpfDeprecated
  • HistoryScale
  • Date
  • Password
  • Label
  • SmootherType
  • IndicatorTSSource

Remarks

  • Text - exposes a string as a multiline text field in the user interface.
  • StringChoice - exposes a string with a discrete number of possible values, using a drop down in the user interface.
  • 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 (PriceComponent enum.)

PeakTroughReversalType
public enum PeakTroughReversalType

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

  • Percent
  • Point
  • ATR
  • ATRPercent

PeakTroughType
public enum PeakTroughType

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

PlotStyle
public enum PlotStyle

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

  • Line
  • Histogram
  • Dots
  • ThickLine
  • ThickHistogram
  • DottedLine
  • DashedLine
  • BooleanDots
  • Bands
  • ZigZag
  • Blocks
  • GradientBlocks
  • BarHistory
  • BarChart
  • HistogramTwoColor
  • Oscillator
  • Cloud
  • Mountain

Remarks

  • 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, which requires that the companion indicators' Bars property be assigned to the same BarHistory (see example). If a BandCompanion could not be found, plots as a line. Alternatively, use PlotIndicatorBands.
  • 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 - Similar to Blocks, but fills the blocks with a gradient.
Example Code
using WealthLab.Backtest;
using System;
using WealthLab.Core;
using WealthLab.Indicators;
using System.Collections.Generic;

namespace WealthScript123
{
	public class FilledBBands : UserStrategyBase
	{
		//create indicators and other objects here, this is executed prior to the main trading loop
		public override void Initialize(BarHistory bars)
		{
		    // Plot filled companion bands
			bbl = BBLower.Series(bars.Close, 20, 2);
			bbu = BBUpper.Series(bars.Close, 20, 2);
			bbl.Bars = bars;
			bbu.Bars = bars;
			PlotIndicator(bbl, WLColor.Pink, PlotStyle.Bands);
			PlotIndicator(bbu, WLColor.Pink);
		}

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

		}

		//declare private variables below
		private BBLower bbl;
		private BBUpper bbu;
	}
}

PositionType
public enum PositionType

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

  • Long
  • Short

PriceComponent
public enum PriceComponent

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

SignalStatus
public enum SignalStatus

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
  • WaitForClose
  • Published
  • FinalOrder
  • HeldForReview

StrategyExecutionMode
public enum StrategyExecutionMode

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

  • Strategy
  • Optimization
  • StreamingChart
  • StrategyMonitor
  • Rankings
  • Evolver
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(), WLColor.Blue, 16);

			switch (ExecutionMode)
			{
				case StrategyExecutionMode.Optimization:
					_isOptimization = true;
					break;
				case StrategyExecutionMode.Strategy:
					_isStrategyWindow = true;
					break;
				case StrategyExecutionMode.StrategyMonitor:
					_isStrategyMonitor = true;
					break;
				case StrategyExecutionMode.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;
	}
}

TextShape
public enum TextShape

TextShape provides an easy way to display a number of special symbols for DrawBarAnnotation() such as triangles, circles, squares, and stars. Possible values are:

  • TriangleUp
  • TriangleDown
  • TriangleHollowUp
  • TriangleHollowDown
  • SquareFilled
  • SquareHollow
  • SquareLeftTick
  • SquareRightTick
  • CircleHollow
  • CircleFilled
  • CircleCrosshair
  • CircleWithX
  • DiamondFilled
  • DiamondHollow
  • HexagonFilled
  • HexagonHollow
  • ArrowUp
  • ArrowDown
  • ArrowRight
  • ArrowLeft
  • ArrowRightLeft
  • StarFilled
  • StarHollow
  • Star8Points
Example Code
using WealthLab.Backtest;
using System;
using WealthLab.Core;
using WealthLab.Indicators;
using System.Collections.Generic;

namespace WealthScript1 
{
    public class MyStrategy : UserStrategyBase
    {
        //create indicators and other objects here, this is executed prior to the main trading loop
        public override void Initialize(BarHistory bars)
        {
			ptc = new PeakTroughCalculator(bars.Close, 5.0, PeakTroughReversalType.Percent);
			foreach (PeakTrough pt in ptc.PeakTroughs)
			{
				if (pt.Type == PeakTroughType.Trough)
					DrawBarAnnotation(TextShape.TriangleHollowUp, pt.XIndex, false, WLColor.Lime, 16);
				else
					DrawBarAnnotation(TextShape.TriangleHollowDown, pt.XIndex, true, WLColor.Red, 16);
			}
        }

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

		//declare private variables below
		PeakTroughCalculator ptc;
    }
}

TradingDayChoice
public enum TradingDayChoice

Identifies the period used in functions such as TradingDaysSince and TradingDaysLeft.


TrailingStopType
public enum TrailingStopType

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

  • PercentC
  • PointC
  • PercentHL
  • PointHL
  • ATR

Remarks

  • 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 by default.

TransactionType
public enum TransactionType

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

  • Buy
  • Sell
  • Short
  • Cover

VerticalAlignment
public enum VerticalAlignment

Specifies the type of vertical alignment used in DrawTextVAlign(). Possible values are:

  • Bottom
  • Center
  • Top