OnExecution()
Previous Topic  Next Topic 

Definition
The OnExecution() method is called on an incoming execution. An execution is another name for a fill of an order.



If you are relying on the OnExecution() method to trigger actions such as the submission of a stop loss order when your entry order is filled ALWAYS reference the properties on the IOrder object property attached to the IExecution object passed into the OnExecution() method.


Method Return Value

This method does not return a value.


Method Parameters

IExecution execution


Syntax
You must override the method in your strategy with the following syntax.


protected override void OnExecution(IExecution execution)
{

}


Examples

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.Token == execution.Order.Token)
        Print(execution.ToString());
}


Additional Reference Samples
Additional reference code samples are available the NinjaScript Educational Resources section of our support forum.