Attached below are the error and trade confirmation screenshots.
Next is the stop exit order code: The error occurs with the "LongentryCeiling"
protected override void OnExecutionUpdate(Execution execution, string executionId, double price, int quantity, MarketPosition marketPosition, string orderId, DateTime time) { #region Longs #region Ceiling Break if (execution.Order.Name == "LongEntryCeiling1" && execution.Order.OrderState == OrderState.Filled) { LongCeilingEntry = execution.Order; } if (LongCeilingEntry != null && LongCeilingEntry == execution.Order && execution.Order.Name == "LongEntryCeiling1" && execution.Order.OrderState == OrderState.Filled) { exPriceCeiling = execution.Price; #region Targets largeLongCeilingTarget = exPriceCeiling + ((SLNormalCeiling*TickSize)*TargetMultiplierCeilin g); stopLongCeiling1 = exPriceCeiling - (SLNormalCeiling*TickSize); stopLongCeiling1a = exPriceCeiling - (NewStopLongCeiling*TickSize); #endregion stopOrderLongEntryCeiling1 = ExitLongStopMarket(2, true, (lotLCeiling*2), stopLongCeiling1,"StopExitLongCeiling1", "LongEntryCeiling1"); //should this be an ExitLongLimit? ExitLongMIT(2, true, lotLCeiling, largeLongCeilingTarget, "ExitProfitLongEntryCeiling1R","LongEntryCeiling1" ); CeilingActive = true; } #endregion #region Basement/Floor1 Break if (execution.Order.Name == "LongEntryBasement1" && execution.Order.OrderState == OrderState.Filled) { LongBasementEntry = execution.Order; } if (LongBasementEntry != null && LongBasementEntry == execution.Order && execution.Order.Name == "LongEntryBasement1" && execution.Order.OrderState == OrderState.Filled) { exPriceBasement = execution.Price; #region Targets largeLongBasementTarget = exPriceBasement + ((SLNormalBasement*TickSize)*TargetMultiplierBasem ent); stopLongBasement1 = exPriceBasement - (SLNormalBasement*TickSize); stopLongBasement1a = exPriceBasement - (NewStopLongBasement*TickSize); #endregion stopOrderLongEntryBasement1 = ExitLongStopMarket(2, true, (lotLBasement*2), stopLongBasement1,"StopExitLongBasement1", "LongEntryBasement1"); //should this be an ExitLongLimit? ExitLongMIT(2, true, lotLBasement, largeLongBasementTarget, "ExitProfitLongEntryBasement1R","LongEntryBasement 1"); BasementActive = true; } #endregion #endregion
Below screenshot shows this instance.
I believe the stop exit code is the exact same in the above instance:
#region Ceiling Break if (execution.Order.Name == "LongEntryCeiling1" && execution.Order.OrderState == OrderState.Filled) { LongCeilingEntry = execution.Order; } if (LongCeilingEntry != null && LongCeilingEntry == execution.Order && execution.Order.Name == "LongEntryCeiling1" && execution.Order.OrderState == OrderState.Filled) { exPriceCeiling = execution.Price; #region Targets largeLongCeilingTarget = exPriceCeiling + ((SLNormalCeiling*TickSize)*TargetMultiplierCeilin g); stopLongCeiling1 = exPriceCeiling - (SLNormalCeiling*TickSize); stopLongCeiling1a = exPriceCeiling - (NewStopLongCeiling*TickSize); #endregion stopOrderLongEntryCeiling1 = ExitLongStopMarket(2, true, (lotLCeiling*2), stopLongCeiling1,"StopExitLongCeiling1", "LongEntryCeiling1"); //should this be an ExitLongLimit? ExitLongMIT(2, true, lotLCeiling, largeLongCeilingTarget, "ExitProfitLongEntryCeiling1R",""); CeilingActive = true; } #endregion
What could be causing the error when the 2 entries are compiled in one strategy? From my analysis it looks like the timing of the stopexit is the issue. Why would it try to place the stop exit at 11am when the entry isn't filled until 11:26am?
Thanks.
Comment