Table of Contents

Class Strategy

Namespace
Balsam
Assembly
Balsam.Backtester.dll

An abstract base class that exposes common methods and properties for testing trading strategies.

public abstract class Strategy : SeriesManager, IStrategy
Inheritance
Strategy
Implements
Derived
Inherited Members
Extension Methods

Properties

AllowMultiplePositions

Gets/sets whether multiple simultaneous positions can be opened for a single symbol. Default is false.

protected bool AllowMultiplePositions { get; set; }

Property Value

bool

AutoReverseOnOppositeEntry

Gets/sets whether the strategy will automatically reverse an existing position if there is an entry signal on the opposite side.

protected bool AutoReverseOnOppositeEntry { get; set; }

Property Value

bool

BarsSinceEntry

Gets the number of bars since entry for the current position or -1 if there is no open position.

protected int BarsSinceEntry { get; }

Property Value

int

BarsSinceExit

Gets the number of bars that have elapsed since the last position was closed or -1 if the system hasn't traded yet.

protected int BarsSinceExit { get; }

Property Value

int

ClosedPositions

Gets a collection of all closed positions.

public PositionCollection ClosedPositions { get; }

Property Value

PositionCollection

CurrentPosition

Gets the current open position or null if there are no open positions. When AllowMultiplePositions is true, reference the OpenPositions collection instead.

protected Position CurrentPosition { get; }

Property Value

Position

DataStore

Gets the underlying data store used to collect and possibly persist all strategy generated trade information.

public DataStoreBase DataStore { get; set; }

Property Value

DataStoreBase

EnforceUniqueSignalNames

Gets/sets whether trades must have unique signal names.

protected bool EnforceUniqueSignalNames { get; set; }

Property Value

bool

EntryDate

Gets the last date a position was opened.

protected DateTime EntryDate { get; }

Property Value

DateTime

EntryPrice

Gets the average entry price or NaN if there is no current position.

protected double EntryPrice { get; }

Property Value

double

ExitDate

Gets the last date a position was closed.

protected DateTime ExitDate { get; }

Property Value

DateTime

ExitPrice

Gets the last price on which an open position was reduced or if no open positions, the average exit price of the last closed position.

protected double ExitPrice { get; }

Property Value

double

IsFirstBar

Gets whether the current bar is the first valid bar being tested.

protected bool IsFirstBar { get; }

Property Value

bool

IsLastBar

Gets whether the current bar is the last valid bar being tested.

protected bool IsLastBar { get; }

Property Value

bool

MarketPosition

Gets the current market position.

protected PositionSide MarketPosition { get; }

Property Value

PositionSide

MoneyManager

Gets/sets the money manager associated with this strategy.

public MoneyManager MoneyManager { get; set; }

Property Value

MoneyManager

MultiplierSize

Gets/sets how muliplier trade size is calculated.

protected MultiplierSizeCalculation MultiplierSize { get; set; }

Property Value

MultiplierSizeCalculation

Name

Gets/sets name of the trading strategy.

public string Name { get; set; }

Property Value

string

OpenPositions

Gets/sets a collection of all positions currently open.

public PositionCollection OpenPositions { get; set; }

Property Value

PositionCollection

OrderHandler

Gets the order handler.

public OrderHandler OrderHandler { get; }

Property Value

OrderHandler

PendingOrders

Gets a collection of pending orders that have been queued for execution the following bar.

public OrderCollection PendingOrders { get; }

Property Value

OrderCollection

Results

Gets the results of the strategy backtest.

public TradeStats Results { get; }

Property Value

TradeStats

SimulationMode

Gets/sets the simulation mode.

public SimulationMode SimulationMode { get; set; }

Property Value

SimulationMode

SimulationOptions

Gets/sets options to control simulation and order handling rules.

public SimulationOptions SimulationOptions { get; set; }

Property Value

SimulationOptions

StrategyVariables

Gets a collection of global variables assigned to this strategy.

protected VariableDictionary StrategyVariables { get; }

Property Value

VariableDictionary

Tag

Gets/sets a convenience field for the user to store any arbitrary object or identifying information.

public object Tag { get; set; }

Property Value

object

TransactionCosts

Gets/sets the transaction cost model applied to this strategy.

public TransactionCostModel TransactionCosts { get; set; }

Property Value

TransactionCostModel

Methods

Buy()

Submits a buy market order for the primary series.

protected void Buy()

Buy(BarSeries)

Submits a buy market order for the specified series.

protected void Buy(BarSeries series)

Parameters

series BarSeries

Buy(BarSeries, string)

Submits a buy market order for the specified series using the specified signal name.

protected void Buy(BarSeries series, string signalName)

Parameters

series BarSeries
signalName string

Buy(string)

Submits a buy market order for the primary series using the specified signal name.

protected void Buy(string signalName)

Parameters

signalName string

BuyClose()

Submits a buy order MOC on the current bar for the primary series.

protected void BuyClose()

BuyClose(BarSeries)

Submits a buy order MOC on the current bar for the specified series.

protected void BuyClose(BarSeries series)

Parameters

series BarSeries

BuyClose(BarSeries, string)

Submits a buy order MOC on the current bar for the specified series using the specified signal name.

protected void BuyClose(BarSeries series, string signalName)

Parameters

series BarSeries
signalName string

BuyClose(string)

Submits a buy order MOC on the current bar for the primary series using the specified signal name.

protected void BuyClose(string signalName)

Parameters

signalName string

BuyLimit(BarSeries, double)

Submits a buy limit order using the specified series and limit price.

protected void BuyLimit(BarSeries series, double limitPrice)

Parameters

series BarSeries
limitPrice double

BuyLimit(BarSeries, double, string)

Submits a buy limit order using the specified parameters.

protected void BuyLimit(BarSeries series, double limitPrice, string signalName)

Parameters

series BarSeries
limitPrice double
signalName string

BuyLimit(double)

Submits a buy limit order using the specified limit price.

protected void BuyLimit(double limitPrice)

Parameters

limitPrice double

BuyLimit(double, string)

Submits a buy limit order using the specified limit price and signal name.

protected void BuyLimit(double limitPrice, string signalName)

Parameters

limitPrice double
signalName string

BuyPair(BarSeries, BarSeries)

Buys the primary series and shorts the secondary series against it.

protected void BuyPair(BarSeries primary, BarSeries secondary)

Parameters

primary BarSeries
secondary BarSeries

BuyPair(BarSeries, BarSeries, string)

Buys the primary series and shorts the secondary series against it using the specified signal name.

protected void BuyPair(BarSeries primary, BarSeries secondary, string signalName)

Parameters

primary BarSeries
secondary BarSeries
signalName string

BuyPairClose(BarSeries, BarSeries)

Buys the primary series and shorts the secondary series against it MOC.

protected void BuyPairClose(BarSeries primary, BarSeries secondary)

Parameters

primary BarSeries
secondary BarSeries

BuyPairClose(BarSeries, BarSeries, string)

Buys the primary series and shorts the secondary series against it MOC using the specified signal name.

protected void BuyPairClose(BarSeries primary, BarSeries secondary, string signalName)

Parameters

primary BarSeries
secondary BarSeries
signalName string

BuyStop(BarSeries, double)

Submits a buy stop order using the specified series and stop price.

protected void BuyStop(BarSeries series, double stopPrice)

Parameters

series BarSeries
stopPrice double

BuyStop(BarSeries, double, string)

Submits a buy stop order using the specified parameters.

protected void BuyStop(BarSeries series, double stopPrice, string signalName)

Parameters

series BarSeries
stopPrice double
signalName string

BuyStop(double)

Submits a buy stop order using the specified stop price.

protected void BuyStop(double stopPrice)

Parameters

stopPrice double

BuyStop(double, string)

Submits a buy stop order using the specified stop price and signal name.

protected void BuyStop(double stopPrice, string signalName)

Parameters

stopPrice double
signalName string

CancelOrder(Order)

Cancels the specified order.

protected void CancelOrder(Order order)

Parameters

order Order

CancelOrder(Order, string)

Cancels the specified order for the reason indicated.

protected void CancelOrder(Order order, string reason)

Parameters

order Order
reason string

CancelPendingOrders()

Cancels pending orders for the primary series or all pending orders if the primary series is null.

protected void CancelPendingOrders()

Clear()

Clears all positions, pending orders, order queue, and DataStore if set.

public void Clear()

Cover()

Submits a market order to cover the current position.

protected void Cover()

Cover(Position)

Submits a market order to cover the specified position.

protected void Cover(Position position)

Parameters

position Position

Cover(Position, string)

Submits a market order to cover the specified position using the specified signal name.

protected void Cover(Position position, string signalName)

Parameters

position Position
signalName string

Cover(string)

Submits a market order to cover the current position using the specified signal name.

protected void Cover(string signalName)

Parameters

signalName string

CoverClose()

Submits a cover order MOC on the current bar for the current position.

protected void CoverClose()

CoverClose(Position)

Submits a cover order MOC on the current bar for the specified position.

protected void CoverClose(Position position)

Parameters

position Position

CoverClose(Position, string)

Submits a cover order MOC on the current bar for the specified position using the specified signal name.

protected void CoverClose(Position position, string signalName)

Parameters

position Position
signalName string

CoverClose(string)

Submits a cover order MOC on the current bar for the current position using the specified signal name.

protected void CoverClose(string signalName)

Parameters

signalName string

CoverLimit(Position, double)

Submits a cover limit order for the specified position using the specified limit price.

protected void CoverLimit(Position position, double limitPrice)

Parameters

position Position
limitPrice double

CoverLimit(Position, double, string)

Submits a cover limit order using the specified parameters.

protected void CoverLimit(Position position, double limitPrice, string signalName)

Parameters

position Position
limitPrice double
signalName string

CoverLimit(double)

Submits a cover limit order for the current position using the specified limit price.

protected void CoverLimit(double limitPrice)

Parameters

limitPrice double

CoverLimit(double, string)

Submits a cover limit order for the current position using the specified limit price and signal name.

protected void CoverLimit(double limitPrice, string signalName)

Parameters

limitPrice double
signalName string

CoverStop(Position, double)

Submits a cover stop order for the specified position using the specified stop price.

protected void CoverStop(Position position, double stopPrice)

Parameters

position Position
stopPrice double

CoverStop(Position, double, string)

Submits a cover stop order using the specified parameters.

protected void CoverStop(Position position, double stopPrice, string signalName)

Parameters

position Position
stopPrice double
signalName string

CoverStop(double)

Submits a cover stop order for the current position using the specified stop price.

protected void CoverStop(double stopPrice)

Parameters

stopPrice double

CoverStop(double, string)

Submits a cover stop order for the current position using the specified stop price and signal name.

protected void CoverStop(double stopPrice, string signalName)

Parameters

stopPrice double
signalName string

ExitAtLimit(Position, double)

Exits the specified position at the specified limit price.

protected void ExitAtLimit(Position position, double limitPrice)

Parameters

position Position
limitPrice double

ExitAtLimit(Position, double, string)

Exits the specified position at a limit using specified signal name.

protected void ExitAtLimit(Position position, double limitPrice, string signalName)

Parameters

position Position
limitPrice double
signalName string

ExitAtLimit(double)

Exits the current position at the specified limit price.

protected void ExitAtLimit(double limitPrice)

Parameters

limitPrice double

ExitAtLimit(double, string)

Exits the current position at the specified limit price using the specified signal name.

protected void ExitAtLimit(double limitPrice, string signalName)

Parameters

limitPrice double
signalName string

ExitAtMarket()

Exits the current position at the market. If current position is null, no order will be submitted.

protected void ExitAtMarket()

ExitAtMarket(Position)

Exits the specified position at the market.

protected void ExitAtMarket(Position position)

Parameters

position Position

ExitAtMarket(Position, string)

Exits the specified position at the market using the specified signal name.

protected void ExitAtMarket(Position position, string signalName)

Parameters

position Position
signalName string

ExitAtMarket(string)

Exits the current position at the market using the specified signal name. If current position is null, no order will be submitted.

protected void ExitAtMarket(string signalName)

Parameters

signalName string

ExitAtTarget()

Exits the current position at the target price found in the position's Target property. If current position is null, no order will be submitted.

protected void ExitAtTarget()

ExitAtTarget(Position)

Exits the specified position at the limit found in the position's Target property.

protected void ExitAtTarget(Position position)

Parameters

position Position

ExitAtTarget(Position, string)

Exits the specified position at the limit found in the position's Target property using the specified signal name.

protected void ExitAtTarget(Position position, string signalName)

Parameters

position Position
signalName string

ExitAtTarget(string)

Exits the current position at the target price found in the position's Target property using the specified signal name. If current position is null, no order will be submitted.

protected void ExitAtTarget(string signalName)

Parameters

signalName string

ExitOnClose()

Exits the current position MOC on the same bar. If current position is null, no order will be submitted. Only available from backtesting.

protected void ExitOnClose()

ExitOnClose(Position)

Exits the specified position MOC on the same bar. Only available from backtesting.

protected void ExitOnClose(Position position)

Parameters

position Position

ExitOnClose(Position, string)

Exits the specified position MOC on the same bar using the specified signal name. Only available from backtesting.

protected void ExitOnClose(Position position, string signalName)

Parameters

position Position
signalName string

ExitOnClose(string)

Exits the current position MOC on the same bar using the specified signal name. If current position is null, no order will be submitted. Only available from backtesting.

protected void ExitOnClose(string signalName)

Parameters

signalName string

ExitOnHorizon(int)

Exits MOC if CurrentPosition.BarsSinceEntry is greater than or equal to the specified horizon.

protected void ExitOnHorizon(int horizon)

Parameters

horizon int

ExitOnHorizon(int, string)

Exits MOC using the specified signal name if CurrentPosition.BarsSinceEntry is greater than or equal to the specified horizon.

protected void ExitOnHorizon(int horizon, string signalName)

Parameters

horizon int
signalName string

ExitOnStop()

Exits the current position at the stop price found in the position's Stop property.

protected void ExitOnStop()

ExitOnStop(Position)

Exits the specified position at the stop price found in the position's Stop property.

protected void ExitOnStop(Position position)

Parameters

position Position

ExitOnStop(Position, string)

Exits the specified position at the stop price found in the position's Stop property using the specified signal name.

protected void ExitOnStop(Position position, string signalName)

Parameters

position Position
signalName string

ExitOnStop(string)

Exits the current position at the stop price found in the position's Stop property using the specified signal name.

protected void ExitOnStop(string signalName)

Parameters

signalName string

GetEventMarkers()

Returns a read-only collection of event markers assuming SnapEvent has been called from within the strategy.

public ReadOnlyCollection<EventMarker> GetEventMarkers()

Returns

ReadOnlyCollection<EventMarker>

GetMarketPosition()

Returns an integer series with +1/0/-1 corresponding to the net market position of long/flat/short respectively. This will not work for Ranking strategies or for multiple symbols.

public IntegerSeries GetMarketPosition()

Returns

IntegerSeries

GetPendingOrders()

Returns an enumerable of pending orders for the primary series or all pending orders if primary series is null.

protected IEnumerable<Order> GetPendingOrders()

Returns

IEnumerable<Order>

GetPlotInstructions()

Returns a read-only collection of plot instructions that have been issued by the strategy, including a default for the primary series.

public ReadOnlyCollection<PlotInstruction> GetPlotInstructions()

Returns

ReadOnlyCollection<PlotInstruction>

IsEndOfDay(TimeSpan)

Returns true if the next bar is after the specified time or 24 hours later.

protected bool IsEndOfDay(TimeSpan eod)

Parameters

eod TimeSpan

Returns

bool

IsEndOfDay(TimeSpan, TimeSpan)

Returns true if the next bar is after the specified time or the timespan between the next bar and the current bar is greater than or equal to the specified gap parameter.

protected bool IsEndOfDay(TimeSpan eod, TimeSpan gap)

Parameters

eod TimeSpan
gap TimeSpan

Returns

bool

Exceptions

InvalidOperationException

IsEndOfWeek()

Returns true if the current date is the last one of the week.

protected bool IsEndOfWeek()

Returns

bool

IsMonthEnd()

Returns true if the current date is the last one of the month.

protected bool IsMonthEnd()

Returns

bool

IsMonthEnd(int)

Returns true if today is n days before month end.

protected bool IsMonthEnd(int days)

Parameters

days int

Returns

bool

Exceptions

InvalidOperationException
ArgumentOutOfRangeException

IsQuarterEnd()

Returns true if the current date is quarter end.

protected bool IsQuarterEnd()

Returns

bool

IsQuarterEnd(int)

Returns true if the current date is n days before quarter end.

protected bool IsQuarterEnd(int days)

Parameters

days int

Returns

bool

IsYearEnd()

Returns true if the current date is the last one of the year.

protected bool IsYearEnd()

Returns

bool

IsYearEnd(int)

Returns true if the current date is the specified number of days before year end.

protected bool IsYearEnd(int days)

Parameters

days int

Returns

bool

Exceptions

InvalidOperationException

Multiplier(Position, double, string)

Scales up or down the specified position using the specified parameters.

protected void Multiplier(Position position, double multiplier, string signalName)

Parameters

position Position
multiplier double
signalName string

Multiplier(double)

Scales up or down the current position using the specified multiplier.

protected void Multiplier(double multiplier)

Parameters

multiplier double

Multiplier(double, string)

Scales up or down the current posiiton using the specified multiplier and signal name.

protected void Multiplier(double multiplier, string signalName)

Parameters

multiplier double
signalName string

MultiplierClose(Position, double, string)

Scales up or down the specified position on the close of the current bar using the specified multiplier and signal name.

protected void MultiplierClose(Position position, double multiplier, string signalName)

Parameters

position Position
multiplier double
signalName string

MultiplierClose(double)

Scales up or down the current position on the close of the current bar using the specified multiplier.

protected void MultiplierClose(double multiplier)

Parameters

multiplier double

MultiplierClose(double, string)

Scales up or down the current position on the close of the current bar using the specified multiplier and signal name.

protected void MultiplierClose(double multiplier, string signalName)

Parameters

multiplier double
signalName string

MultiplierLimit(Position, double, double, string)

Scales up or down the specified position using the specified parameters.

protected void MultiplierLimit(Position position, double multiplier, double limitPrice, string signalName)

Parameters

position Position
multiplier double
limitPrice double
signalName string

MultiplierLimit(double, double)

Scales up or down the current position using the specified multiplier at the specified limit price.

protected void MultiplierLimit(double multiplier, double limitPrice)

Parameters

multiplier double
limitPrice double

MultiplierLimit(double, double, string)

Scales up or down the current position using the specified parameters.

protected void MultiplierLimit(double multiplier, double limitPrice, string signalName)

Parameters

multiplier double
limitPrice double
signalName string

MultiplierStop(Position, double, double, string)

Scales up or down the specified position using the specified parameters.

protected void MultiplierStop(Position position, double multiplier, double stopPrice, string signalName)

Parameters

position Position
multiplier double
stopPrice double
signalName string

MultiplierStop(double, double)

Scales up or down the current position at the specified stop.

protected void MultiplierStop(double multiplier, double stopPrice)

Parameters

multiplier double
stopPrice double

MultiplierStop(double, double, string)

Scales up or down the current position using the specified parameters.

protected void MultiplierStop(double multiplier, double stopPrice, string signalName)

Parameters

multiplier double
stopPrice double
signalName string

OnBarClose()

Called once for each bar in the primary series. Orders submitted here are for execution on the next bar.

protected virtual void OnBarClose()

OnBarOpen()

Called after the open of the primary series. Pre-existing market orders will already have been executed. Only the open price of the CurrentBar property is available. All other series will still have the prior bar's date. Orders cannot be submitted from this method in production mode.

protected virtual void OnBarOpen()

OnOrderStatusChanged(OrderStatusEventArgs)

Called when the status of an order changes.

protected virtual void OnOrderStatusChanged(OrderStatusEventArgs e)

Parameters

e OrderStatusEventArgs

OnOrderSubmitting(Order)

Called before an order is submitted to the execution simulation routine.

protected virtual void OnOrderSubmitting(Order order)

Parameters

order Order

OnPositionClosed(Position)

Called when a position is closed.

protected virtual void OnPositionClosed(Position position)

Parameters

position Position

OnPositionClosing(Position)

Called when a position is being closed.

protected virtual void OnPositionClosing(Position position)

Parameters

position Position

OnPositionOpened(Position)

Called after a position is opened.

protected virtual void OnPositionOpened(Position position)

Parameters

position Position

OnPositionOpening(Position)

Called when a position is being opened.

protected virtual void OnPositionOpening(Position position)

Parameters

position Position

OnRoll(Roll, Position)

Called when a roll is processed.

protected virtual void OnRoll(Roll roll, Position position)

Parameters

roll Roll

The roll object.

position Position

The affected position.

OnSimulationComplete(TradeStats)

Called after a simulation is complete and TradeStats have been calculated.

protected virtual void OnSimulationComplete(TradeStats results)

Parameters

results TradeStats

OnStrategyStart()

Called before bars are processed. Useful for indicator setup or other initialization tasks.

protected virtual void OnStrategyStart()

OnStrategyStop()

Called after all all bars have been processed and before any money management has been run.

protected virtual void OnStrategyStop()

Peek()

Returns the next bar in the future for the primary series or null if it is the last bar. For use in backtesting only.

protected Bar Peek()

Returns

Bar

Peek(BarSeries)

Returns the next bar in the future for the specified series. For use in backtesting only.

protected Bar Peek(BarSeries series)

Parameters

series BarSeries

Returns

Bar

Peek(BarSeries, int)

Returns the specified number of bars in the future relative to the current bar for the specified series or null if the specified bars peeks beyond the last bar. For use in backtesting only.

protected Bar Peek(BarSeries series, int bars)

Parameters

series BarSeries
bars int

Returns

Bar

Peek(int)

Returns the bar the specified number of bars in the future for the primary series. For use in backtesting only.

protected Bar Peek(int bars)

Parameters

bars int

Returns

Bar

Plot(ISeries, int, Color)

Plots a series with the specified settings.

protected void Plot(ISeries series, int pane, Color color)

Parameters

series ISeries

The series to be plotted.

pane int

The pane to be used. 0 is the default price pane.

color Color

The color of the plot.

Plot(ISeries, int, Color, string, int, string, float)

Plots a series with the specified settings.

protected void Plot(ISeries series, int pane, Color color, string chartType = "Line", int width = 1, string lineStyle = "Solid", float paneSize = NaN)

Parameters

series ISeries

The series to be plotted.

pane int

The pane to be used. 0 is the default price pane.

color Color

The color.

chartType string

Valid chart types include Stock, Candlestick, Line, Column and Point.

width int

The width of the plot.

lineStyle string

The line style. Valid types include Solid, Dot, Dash, DashDot and DashDotDot.

paneSize float

The size of the pane. NaN will autosize, typically to 25% of total chart height.

Plot(PlotInstruction)

Plots a custom PlotInstruction.

protected void Plot(PlotInstruction instruction)

Parameters

instruction PlotInstruction

Plot(double, int, Color, string, int)

Plots a horizontal line with the specified settings.

protected void Plot(double yValue, int pane, Color color, string lineStyle = "Solid", int width = 1)

Parameters

yValue double
pane int
color Color
lineStyle string
width int

Rebalance(IEnumerable<Tuple<string, PositionSide>>)

Generates orders to rebalance open positions to look like the specified enumerable of symbol, PositionSide. Experimental.

protected void Rebalance(IEnumerable<Tuple<string, PositionSide>> indications)

Parameters

indications IEnumerable<Tuple<string, PositionSide>>

Run(Type, VariableDictionary, IEnumerable<BarSeries>)

Runs multiple simulations in parallel returning a merged datastore.

public static DataStoreBase Run(Type strategy, VariableDictionary strategyProperties, IEnumerable<BarSeries> data)

Parameters

strategy Type
strategyProperties VariableDictionary
data IEnumerable<BarSeries>

Returns

DataStoreBase

Run(Type, VariableDictionary, IEnumerable<BarSeries>, TextWriter, CancellationToken)

Runs multiple simulations in parallel returning a merged datastore.

public static DataStoreBase Run(Type strategy, VariableDictionary strategyProperties, IEnumerable<BarSeries> data, TextWriter output, CancellationToken token)

Parameters

strategy Type
strategyProperties VariableDictionary
data IEnumerable<BarSeries>
output TextWriter
token CancellationToken

Returns

DataStoreBase

RunSimulation()

Runs the simulation.

public void RunSimulation()

RunSimulation(BarSeries)

Sets PrimarySeries to the specified BarSeries and runs the simulation.

public void RunSimulation(BarSeries series)

Parameters

series BarSeries

The series to test.

RunSimulation(IEnumerable<BarSeries>)

Runs the simulation on the specified collection of BarSeries.

public void RunSimulation(IEnumerable<BarSeries> series)

Parameters

series IEnumerable<BarSeries>

RunSimulation(IEnumerable<BarSeries>, TextWriter)

Runs the simulation on the specified collection of BarSeries. Prints progress messages to output.

public void RunSimulation(IEnumerable<BarSeries> series, TextWriter output)

Parameters

series IEnumerable<BarSeries>
output TextWriter

RunSimulation(TextWriter)

Runs the simulation.

public void RunSimulation(TextWriter output)

Parameters

output TextWriter

Sell()

Submits a sell market order for the current position.

protected void Sell()

Sell(Position)

Submits a sell market order for the specified position.

protected void Sell(Position position)

Parameters

position Position

Sell(Position, string)

Submits a sell market order for the specified position using the specified signal name.

protected void Sell(Position position, string signalName)

Parameters

position Position
signalName string

Sell(string)

Submits a sell market order for the current position using the specified signal name.

protected void Sell(string signalName)

Parameters

signalName string

SellClose()

Submits a sell order MOC on the current bar for the current position.

protected void SellClose()

SellClose(Position)

Submits a sell order MOC on the current bar for the specified position.

protected void SellClose(Position position)

Parameters

position Position

SellClose(Position, string)

Submits a sell order MOC on the current bar for the specified position using the specified signal name.

protected void SellClose(Position position, string signalName)

Parameters

position Position
signalName string

SellClose(string)

Submits a sell order MOC on the current bar for the current position using the specified signal name.

protected void SellClose(string signalName)

Parameters

signalName string

SellLimit(Position, double)

Submits a sell limit order for the specified position using the specified limit price.

protected void SellLimit(Position position, double limitPrice)

Parameters

position Position
limitPrice double

SellLimit(Position, double, string)

Submits a sell limit order using the specified parameters.

protected void SellLimit(Position position, double limitPrice, string signalName)

Parameters

position Position
limitPrice double
signalName string

SellLimit(double)

Submits a limit order for the current position using the specified limit price.

protected void SellLimit(double limitPrice)

Parameters

limitPrice double

SellLimit(double, string)

Submits a limit order for the current position using the specified limit price and signal name.

protected void SellLimit(double limitPrice, string signalName)

Parameters

limitPrice double
signalName string

SellShort()

Submits a sell short market order for the primary series.

protected void SellShort()

SellShort(BarSeries)

Submits a sell short market order for the specified series.

protected void SellShort(BarSeries series)

Parameters

series BarSeries

SellShort(BarSeries, string)

Submits a sell short market order for the specified series using the specified signal name.

protected void SellShort(BarSeries series, string signalName)

Parameters

series BarSeries
signalName string

SellShort(string)

Submits a sell short market order for the primary series using the specified signal name.

protected void SellShort(string signalName)

Parameters

signalName string

SellShortClose()

Submits a MOC sell short order on the current bar for the primary series.

protected void SellShortClose()

SellShortClose(BarSeries)

Submits a MOC sell short order on the current bar for the specified series.

protected void SellShortClose(BarSeries series)

Parameters

series BarSeries

SellShortClose(BarSeries, string)

Submits a MOC sell short order on the current bar for the specified series using the specified signal name.

protected void SellShortClose(BarSeries series, string signalName)

Parameters

series BarSeries
signalName string

SellShortClose(string)

Submits a MOC sell short order on the current bar for the primary series using the specified signal name.

protected void SellShortClose(string signalName)

Parameters

signalName string

SellShortLimit(BarSeries, double)

Submits a sell short limit order for the specified series using the specified limit price.

protected void SellShortLimit(BarSeries series, double limitPrice)

Parameters

series BarSeries
limitPrice double

SellShortLimit(BarSeries, double, string)

Submits a sell short limit order using the specified parameters.

protected void SellShortLimit(BarSeries series, double limitPrice, string signalName)

Parameters

series BarSeries
limitPrice double
signalName string

SellShortLimit(double)

Submits a sell short limit order for the primary series using the specified limit price.

protected void SellShortLimit(double limitPrice)

Parameters

limitPrice double

SellShortLimit(double, string)

Submits a sell short limit order for the primary series using the specified limit price and signal name.

protected void SellShortLimit(double limitPrice, string signalName)

Parameters

limitPrice double
signalName string

SellShortPair(BarSeries, BarSeries)

Sells short the primary series buying the secondary series against it.

protected void SellShortPair(BarSeries primary, BarSeries secondary)

Parameters

primary BarSeries
secondary BarSeries

SellShortPair(BarSeries, BarSeries, string)

Sells short the primary series buying the secondary against it using the specified signal name.

protected void SellShortPair(BarSeries primary, BarSeries secondary, string signalName)

Parameters

primary BarSeries
secondary BarSeries
signalName string

SellShortPairClose(BarSeries, BarSeries)

Sells short the primary series buying the secondary series against it MOC.

protected void SellShortPairClose(BarSeries primary, BarSeries secondary)

Parameters

primary BarSeries
secondary BarSeries

SellShortPairClose(BarSeries, BarSeries, string)

Sells short the primary series buying the secondary series against it MOC using the specified signal name.

protected void SellShortPairClose(BarSeries primary, BarSeries secondary, string signalName)

Parameters

primary BarSeries
secondary BarSeries
signalName string

SellShortStop(BarSeries, double)

Submits a sell short stop order for the specified series using the specified stop price.

protected void SellShortStop(BarSeries series, double stopPrice)

Parameters

series BarSeries
stopPrice double

SellShortStop(BarSeries, double, string)

Submits a sell short stop order using the specified parameters.

protected void SellShortStop(BarSeries series, double stopPrice, string signalName)

Parameters

series BarSeries
stopPrice double
signalName string

SellShortStop(double)

Submits a sell short stop order for the primary series using the specified stop price.

protected void SellShortStop(double stopPrice)

Parameters

stopPrice double

SellShortStop(double, string)

Submits a sell short stop order for the primary series using the specified stop price and signal name.

protected void SellShortStop(double stopPrice, string signalName)

Parameters

stopPrice double
signalName string

SellStop(Position, double)

Submits a sell stop order for the specified position using the specified stop price.

protected void SellStop(Position position, double stopPrice)

Parameters

position Position
stopPrice double

SellStop(Position, double, string)

Submits a sell stop order using the specified parameters.

protected void SellStop(Position position, double stopPrice, string signalName)

Parameters

position Position
stopPrice double
signalName string

SellStop(double)

Submits a sell stop order for the current position using the specified stop price.

protected void SellStop(double stopPrice)

Parameters

stopPrice double

SellStop(double, string)

Submits a sell stop order for the current position using the specified stop price and signal name.

protected void SellStop(double stopPrice, string signalName)

Parameters

stopPrice double
signalName string

SetUserRisk(Position, double)

Used to inform the money manager of risk even when not using stops which calculate risk automatically.

protected void SetUserRisk(Position position, double risk)

Parameters

position Position
risk double

SnapEvent(object)

Captures the current index for event analysis.

protected void SnapEvent(object eventValue = null)

Parameters

eventValue object

Stop()

Stops a running simulation at the earliest opportunity. Code will resume at OnStrategyStop.

protected void Stop()

SubmitOrder(Order)

Submits the specified order.

protected void SubmitOrder(Order order)

Parameters

order Order

Events

OrderStatusChanged

Raised when the status of an order changes.

public event EventHandler<OrderStatusEventArgs> OrderStatusChanged

Event Type

EventHandler<OrderStatusEventArgs>