Strategy

<< Click to Display Table of Contents >>

Navigation:  NinjaScript > Language Reference >

Strategy

Previous page Return to chapter overview Next page

The methods and properties covered in this section are unique to custom strategy development.

 

In this section

Account

Represents the real-world or simulation Account configured for the strategy.

AddChartIndicator()

Adds an indicator to the strategy only for the purpose of displaying it on a chart.

AddPerformanceMetric()

Adds an instance of custom Performance Metric to a strategy used in strategy calculations.

ATM Strategy Methods

Adds ATM strategies to manage your position

BarsRequiredToTrade

The number of historical bars required before the strategy starts processing order methods called in the OnBarUpdate() method.

BarsSinceEntryExecution()

Returns the number of bars that have elapsed since the last specified entry.

BarsSinceExitExecution()

Returns the number of bars that have elapsed since the last specified exit.

ChartIndicators

Contains a collection of Indicators which have been added to the strategy instance using AddChartIndicator().

CloseStrategy()

Cancels all working orders, closes any existing positions, and finally disables the strategy.

ConnectionLossHandling

Sets the manner in which your strategy will behave when a connection loss is detected.

DaysToLoad

Determines the number of trading days which will be configured when loading the strategy from the Strategies Grid.

DefaultQuantity

An order size variable that can be set either programmatically or overriden via the Strategy that determines the quantity of an entry order.

DisconnectDelaySeconds

Determines the amount of time a disconnect would have to last before connection loss handling takes action.

EntriesPerDirection

Determines the maximum number of entries allowed per direction while a position is active based on the EntryHandling property.

EntryHandling

Sets the manner in how entry orders will handle.

Execution

Represents a read only interface that exposes information regarding an execution (filled order) resulting from an order and is passed as a parameter in the OnExecutionUpdate() method.

ExitOnSessionCloseSeconds

The number of seconds before the actual session end time that the "IsExitOnSessionCloseStrategy" function will trigger.

IncludeCommission

Determines if the strategy performance results will include commission on a historical backtest.

IncludeTradeHistoryInBacktest

Determines if the strategy will save orders, trades, and execution history.

IsAdoptAccountPositionAware

Determines if the strategy is programmed in a manner capable of handling  real-world account positions.

IsExitOnSessionCloseStrategy

Determines if the strategy will cancel all strategy generated orders and close all open strategy positions at the close of the session.

IsFillLimitOnTouch

Determines if the strategy will use a more liberal fill algorithm for back-testing purposes only.

IsInstantiatedOnEachOptimizationIteration

Determines if the strategy should be re-instantiated (re-created) after each optimization run when using the Strategy Analyzer Optimizer.

IsTradingHoursBreakLineVisible

Plots trading hours break lines on the indicator panel.

IsWaitUntilFlat

Indicates the strategy is currently waiting until a flat position is detected before submitting live orders.

NumberRestartAttempts

Determines the maximum number of restart attempts allowed within the last x minutes defined in RestartsWithinMinutes when the strategy experiences a connection loss.

OnAccountItemUpdate()

An event driven method used for strategies which is called for each AccountItem update for the account on which the strategy is running.

OnExecutionUpdate()

An event driven method which is called on an incoming execution of an order managed by a strategy.

OnOrderTrace()

An event driven method used for strategies which will allow you to customize the output of TraceOrders.

OnOrderUpdate()

An event driven method which is called each time an order managed by a strategy changes state.

OnPositionUpdate()

An event driven method which is called each time the position of a strategy changes state.

OptimizationPeriod

Reserved for Walk-Forward Optimization, this property determines the number of days used for the "in sample" backtest period for a given strategy.  See also TestPeriod.

Order

Represents a read only interface that exposes information regarding an order.

Order Methods

NinjaScript provides several approaches you can use for order placement within your NinjaScript strategy.

OrderFillResolution

Determines how strategy orders are filled during historical states.

OrderFillResolutionType

Determines the bars type which will be used for historical fill processing.

OrderFillResolutionValue

Determines the bars period interval value which will be used for historical fill processing.

PerformanceMetrics

Holds an array of PerformanceMetrics objects that represent custom metrics that can be used for strategy calcuations.

Plots

A collection holding all of the Plot objects that define their visualization characteristics.

Position

Represents position related information that pertains to an instance of a strategy.

PositionAccount

Represents position related information that pertains to real-world account (live or simulation).

Positions

Holds an array of Position objects that represent positions managed by the strategy.

PositionsAccount

Holds an array of PositionAccount objects that represent positions managed by the strategy's account.

RealtimeErrorHandling

Defines the behavior of a strategy when a strategy generated order is returned from the broker's server in a "Rejected" state.

RestartsWithinMinutes

Determines within how many minutes the strategy will attempt to restart.

SetOrderQuantity

Determines how order sizes are calculated for a given strategy.

Slippage

Sets the amount of slippage in ticks per execution used in performance calculations during backtests.

StartBehavior

Sets the start behavior of the strategy. See Syncing Account Positions for more information.

StopTargetHandling

Determines how stop and target orders are submitted during an entry order execution.

StrategyBaseConverter

A custom TypeConverter class handling the designed behavior of an strategy's property descriptor collection.

SystemPerformance

The SystemPerformance object holds all trades and trade performance data generated by a strategy.

TestPeriod

Reserved for Walk-Forward Optimization, this property determines the number of days used for the "out of sample" backtest period for a given strategy.

TimeInForce

Sets the time in force property for all orders generated by a strategy.

TraceOrders

Determines if OnOrderTrace() would be called for a given strategy.

Trade

A Trade is a completed buy/sell or sell/buy transaction. It consists of an entry and exit execution.

TradeCollection

A collection of Trade objects.

TradesPerformanceValues

Performance values of a collection of Trade objects.

WaitForOcoClosingBracket

Determines if the strategy will submit both legs of an OCO bracket before submitting the pair to the broker.