Support Board
Date/Time: Mon, 16 Jun 2025 23:38:57 +0000
Post From: Problem with incorrect price being assigned when calling sc.ModifyOrder.
[2025-04-30 06:39:57] |
Richard Novak - Posts: 26 |
Hello, I'm having a problem with sc.ModifyOrder assigning the incorrect price for a stop limit order. This is occurring with the trade evaluation service. My code is shown below with the log output. A request was made to set price 1 to 19,426 and price 2 to 19,427. After sending the request I retrieved the order data using a GetOrderByOrderID call. Price 1 was set to 19,527. Price2 was set to 19,528. if (ModifyStopLossOrder == true) { double NewOrderQuantity = std.StopLossOrder->OrderData.OrderQuantity + FillEventQuantity; s_SCNewOrder ModifyOrder; ModifyOrder.InternalOrderID = std.StopLossOrder->InternalOrderID; ModifyOrder.OrderQuantity = NewOrderQuantity; if (EntryOrder.OrderData.BuySell == BSE_BUY) { ModifyOrder.Price1 = EntryOrderAveragePrice - (StopLossTicks * sc.TickSize); // stop loss price ModifyOrder.Price2 = StopLossPrice + (4 * sc.TickSize); // stop loss limit price if (debug) { Buffer.Format("PlaceAdjustStopLossOrder - Existing BSE_BUY StopLossOrder.InternalOrderID = %d, Price = %f, Limit Price = %lf, Quantity = %lf", std.StopLossOrder->InternalOrderID, ModifyOrder.Price1, ModifyOrder.Price2, NewOrderQuantity); sc.AddMessageToLog(Buffer, 1); } } else { ModifyOrder.Price1 = EntryOrderAveragePrice + (StopLossTicks * sc.TickSize); // stop loss price ModifyOrder.Price2 = StopLossPrice - (4 * sc.TickSize); // stop loss limit price if (debug) { Buffer.Format("PlaceAdjustStopLossOrder - Existing BSE_SELL StopLossOrder.InternalOrderID = %d, Price = %f, Limit Price = %lf, Quantity = %lf", std.StopLossOrder->InternalOrderID, ModifyOrder.Price1, ModifyOrder.Price2, NewOrderQuantity); sc.AddMessageToLog(Buffer, 1); } } int Result = sc.ModifyOrder(ModifyOrder); if (Result > 0) { if (debug) { Buffer.Format("PlaceAdjustStopLossOrder - sc.ModifyOrder Result > 0, Result = %d, InternalOrderID = %d, ModifyOrder.Price 1 = %lf, ModifyOrder.Price2 = %lf", Result, ModifyOrder.InternalOrderID, ModifyOrder.Price1, ModifyOrder.Price2); sc.AddMessageToLog(Buffer, 1); } std.StopLossOrder->OrderQuantity = NewOrderQuantity; std.StopLossOrder->Price = ModifyOrder.Price1; // test to read current order status s_SCTradeOrder TestOrder; int TestResult = sc.GetOrderByOrderID(ModifyOrder.InternalOrderID, TestOrder); Buffer.Format("PlaceAdjustStopLossOrder - Post Modify Stop Loss Order Callback - InternalOrderID = %d, Price = %lf, Limit Price = %lf", ModifyOrder.InternalOrderID, TestOrder.Price1, TestOrder.Price2); sc.AddMessageToLog(Buffer, 1); } else { Buffer.Format("PlaceAdjustStopLossOrder - Failed to modify existing stop loss order InternalOrderID = %d", std.StopLossOrder->InternalOrderID); sc.AddMessageToLog(Buffer, 1); } } The log output from the AddMessageToLog calls above is shown below. 2025-04-30 01:11:55.280 | Chart: MNQM25[M] 30 Sec #12 | Study: FCM Trading System Study | PlaceAdjustStopLossOrder - Existing BSE_BUY StopLossOrder.InternalOrderID = 45989, Price = 19426.083333, Limit Price = 19427.083333, Quantity = 6.000000 * 2025-04-30 01:11:55.281 | Chart: MNQM25[M] 30 Sec #12 | Study: FCM Trading System Study | PlaceAdjustStopLossOrder - sc.ModifyOrder Result > 0, Result = 1, InternalOrderID = 45989, ModifyOrder.Price 1 = 19426.083333, ModifyOrder.Price2 = 19427.083333 * 2025-04-30 01:11:55.281 | Chart: MNQM25[M] 30 Sec #12 | Study: FCM Trading System Study | PlaceAdjustStopLossOrder - Post Modify Stop Loss Order Callback - InternalOrderID = 45989, Price = 19527.750000, Limit Price = 19528.750000 * The trade activity log out related to order 45989 is shown below. I also attached a screen shot of the activity log to make it easier to view. ActivityType DateTime TransDateTime Symbol OrderActionSource InternalOrderID ServiceOrderID OrderType Quantity BuySell Price Price2 OrderStatus FillPrice FilledQuantity TradeAccount OpenClose ParentInternalOrderID PositionQuantity FillExecutionServiceID HighDuringPosition LowDuringPosition Note AccountBalance ExchangeOrderID ClientOrderID TimeInForce Username IsAutomated Orders 2025-04-30 01:11:26.060051 2025-04-30 01:11:26.060032 MNQM25 Trading Evaluator (New). Info: Order from DTC client #94241. Sierra Chart. 174.54.35.220 | Client text: Tag: StopLossOrder Buy. Text: Tag: StopLossOrder Buy 45989 27817524 Stop Limit 2 Sell 19426.75 19427.75 Pending Open fcm_ldt Close 2 StopLossOrder Buy 0.00 45989.89569 Good till Canceled Richard Novak Y Orders 2025-04-30 01:11:26.060093 2025-04-30 01:11:26.060091 MNQM25 Trading Evaluator (Order update). Info: Simulated order accepted. Text: Tag: StopLossOrder Buy 45989 27817524 Stop Limit 2 Sell 19426.75 19427.75 Open fcm_ldt Close 2 StopLossOrder Buy 0.00 27817524 45989.89569 Good till Canceled Richard Novak Y Orders 2025-04-30 01:11:26.060103 2025-04-30 01:11:26.060102 MNQM25 Trading Evaluator (New). Info: Order from DTC client #94241. Sierra Chart. 174.54.35.220 45990 27817525 Limit 1 Sell 19537.25 Pending Open fcm_ldt Close 2 0.00 45990.97473 Good till Canceled Richard Novak Y Orders 2025-04-30 01:11:26.213169 2025-04-30 01:11:26.213166 MNQM25 Auto-trade order modification: MNQM25[M] 30 Sec #12 | FCM Trading System Study. Requested Price: 19527.75. Requested Quantity: 2 45989 27817524 Stop Limit 2 Sell 19426.75 19427.75 Pending Modify fcm_ldt Close 2 StopLossOrder Buy 0.00 27817524 45989.89569 Good till Canceled Richard Novak Y Orders 2025-04-30 01:11:26.275828 2025-04-30 01:11:26.275822 MNQM25 Trading Evaluator (Order update). Info: Simulated order accepted 45990 27817525 Limit 1 Sell 19537.25 Open fcm_ldt Close 2 0.00 27817525 45990.97473 Good till Canceled Richard Novak Y Orders 2025-04-30 01:11:26.275888 2025-04-30 01:11:26.275886 MNQM25 Trading Evaluator (New). Info: Order from DTC client #94241. Sierra Chart. 174.54.35.220 45991 27817526 Limit 1 Sell 19547.25 Pending Open fcm_ldt Close 2 0.00 45991.51616 Good till Canceled Richard Novak Y Orders 2025-04-30 01:11:26.275920 2025-04-30 01:11:26.275919 MNQM25 Trading Evaluator (Order update). Info: Simulated order accepted 45991 27817526 Limit 1 Sell 19547.25 Open fcm_ldt Close 2 0.00 27817526 45991.51616 Good till Canceled Richard Novak Y Orders 2025-04-30 01:11:26.276063 2025-04-30 01:11:26.276061 MNQM25 Trading Evaluator (Cancel/Replace complete). Info: Simulated order modify complete. Text: Tag: StopLossOrder Buy 45989 27817524 Stop Limit 2 Sell 19527.75 19528.75 Open fcm_ldt Close 2 StopLossOrder Buy 0.00 27817524 45989.89569 Good till Canceled Richard Novak Y Thanks, Richard Novak |
![]() |