NinjaScript > Language Reference > Strategy >

IExecution

Print this Topic Previous pageReturn to chapter overviewNext page

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

 

* The "Price" property may return a value that is not aligned to the underlying instruments tick size. This can happen if the original order price was submitted not aligned to tick size or if the period in time being backtested contains split/dividend back adjusted data that is also not aligned to tick size. However, most if not all execution grid displays will display a rounded to tick size value. You can also use the method Round2TickSize().

 

Methods and Properties

Commission

A double value representing the commission of an execution

ExecutionId

A string value representing the exchange generated execution id

Instrument

An Instrument value representing the instrument of an order

MarketPosition

Possible values are:

MarketPosition.Long

MarketPosition.Short

Name

A string representing the name of an order which can be provided by the entry or exit signal name

Order

An IOrder value representing an order associated to the execution. Note: Not all executions will have associated IOrder objects (e.g.ExitOnClose executions)

Price

A double value representing the price of an execution

Quantity

An int value representing quantity of an execution

Time

A DateTime structure representing the time the execution occurred

Token

A string representing the unique id of an execution

ToString()

A string representation of an execution

 

 

Examples

// Example #1

// Finding the executions of a particular IOrder object

private IOrder entryOrder = null;

 

protected override void OnBarUpdate()
{
    if (entryOrder == null && Close[0] > Open[0])
         entryOrder = EnterLong();
}

 

protected override void OnExecution(IExecution execution)
{
    if (entryOrder != null && entryOrder == execution.Order)
         Print(execution.ToString());
}

 

 

// Example #2

// Generic execution logic not specific to a particular IOrder object

protected override void OnExecution(IExecution execution)
{

    // Remember to check the underlying IOrder object for null before trying to access its properties
    if (execution.Order != null && execution.Order.OrderState == OrderState.Filled)
         Print(execution.ToString());
}