I´m working for years in NT7 with handling setstoploss in onexecution. But now in NT8 I have issues because SetStopLoss is not moved to new price with fill of contract1. I have in the code (reading the reference samples before asking this question):
protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time)
{
if (entryOrderS1a != null && entryOrderS1a == execution.Order) {
if (execution.Order.OrderState == OrderState.Filled || execution.Order.OrderState == OrderState.PartFilled || (execution.Order.OrderState == OrderState.Cancelled && execution.Order.Filled > 0))
{avgFillSa=execution.Order.AverageFillPrice;}
}
if(execution.Name=="Profit target" && execution.Order.FromEntrySignal=="S1a")
{SetStopLoss("S1b", CalculationMode.Price, avgFillSa+2*TickSize, false);}}
What I´m doing wrong in NT8 please?
Thank you!
Tony
Comment