Definition
The OnExecution() method is called on an incoming execution. An execution is another name for a fill of an order.
• | Programming to this method is considered advanced programming and exposed for experienced programmers |
• | An order can generate multiple executions (partial fills) |
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 == execution.Order)
Print(execution.ToString());
}
protected override void OnExecution(IExecution execution)
{
if (execution.Order != null && execution.Order.OrderState == OrderState.Filled)
Print(execution.ToString());
}
|
Additional Reference Samples
Additional reference code samples are available the NinjaScript Educational Resources section of our support forum.
|