protectedoverridevoid OnExecution(IExecution execution)
{
if (entryLongOrderN != null && entryLongOrderN.Token == execution.Order.Token)
{
if (execution.Order.OrderState == OrderState.Filled
|| execution.Order.OrderState == OrderState.PartFilled
|| (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
{
stopLongOrderN = ExitLongStop(1, true, execution.Order.Filled, execution.Order.AvgFillPrice - (loss * TickSize), "MyLongStopN", "MyLongN");
targetLongOrderN = ExitLongLimit(1, true, execution.Order.Filled, execution.Order.AvgFillPrice + (profit * TickSize), "MyLongTargetN", "MyLongN");
if (execution.Order.OrderState != OrderState.PartFilled)
{
entryLongOrderN = null;
}
}
}
-------------------------------------------------------------------------------------------------------------
protectedoverridevoid OnOrderUpdate(IOrder order)
if (stopLongOrderN != null && stopLongOrderN.Token == order.Token)
{
// If our exit order is filled we want to reset myEntryOrder so we can submit orders again.
if (order.OrderState == OrderState.Filled)
entryLongOrderN = null;
// If our exit order encounters some problems we will resubmit the order again.
elseif (order.OrderState == OrderState.Cancelled || order.OrderState == OrderState.Rejected)
{
if (Positions[1].MarketPosition == MarketPosition.Long)
stopLongOrderN = ExitLongStop(1, true, stopLongOrderN.Quantity, Positions[1].AvgPrice - (loss * TickSize), "MyLongStopN", "MyLongN");
}
}
.... and same for target
On market replay connection all is OK.
But ONLINE my strategy may enter in several trades and exit of them without problems.... and after that strategy enter in position but stop and take orders don't appear.
Thank you.



Comment