Support Board
Date/Time: Thu, 30 Apr 2026 04:55:20 +0000
Post From: ACSIL: How to clear a phantom order from local tracking when broker no longer has it
| [2026-04-29 20:41:38] |
| User214239 - Posts: 41 |
|
I need help with an ACSIL custom auto-trading study. The study trades MNQM6.CME from an NQM6.CME chart using the "Trade and Current Quote Symbol" feature with "Use as Trade Only Symbol = Yes." Data feed is Rithmic Direct (DTC). Sierra Chart version is current. After certain trades, a stop order ends up "stuck" displayed on the chart with a status of Open even though the broker (Rithmic) no longer has any record of the order. The order cannot be cancelled by my study via sc.CancelOrder() because sc.GetOrderByIndex() does not return it in the enumeration. It can only be cleared by the manually clicking the X on the order on the chart which takes 10+ seconds to actually return a Canceled status (presumably because Rithmic has to time-out the request since the order doesn't exist there). Trace of a typical incident (from Trade Activity Log): 09:57:04.708851 Order 24069 (Limit/Buy) -> Filled (target hit, position now flat) 09:57:04.709976 Order 24070 (Stop/Buy) -> Pending Cancel (native OCO firing) 09:57:04.710891 Order 24070 (Stop/Buy) -> Canceled (cancel accepted) 09:57:04.710939 Order 24070 (Stop/Buy) -> Open (resurrection, ~50us later) 09:57:04.710939 OAS: "Order modification failed | Rithmic Direct - DTC" 09:57:05.388742 Order 24070 -> Pending Modify (Move-to-BE attempts modify) 09:57:05.443337 Order 24070 -> Open (modification fails) (order sits in Open state, visible on chart, no Rithmic order behind it) 09:57:48.300586 Order 24070 -> Pending Cancel (manual cancel via chart UI) 09:57:58.356636 Order 24070 -> Canceled (10s later, finally clears) I've confirmed during these incidents that Rithmic's own order display shows zero working orders for the account. So the order genuinely does not exist on the broker side. It exists only in Sierra Chart's local tracking. What my study sees during the phantom period: sc.GetTradePositionForSymbolAndAccount(Pos, TradingSymbol, sc.SelectedTradeAccount) returns PositionQuantity = 0 (correct, I'm flat) Pos.WorkingOrdersExist = 1 (incorrect, no real working orders exist) Iterating sc.GetOrderByIndex(idx, ord) from 0 returns no orders matching TradingSymbol and TradeAccount — the phantom order is not in the enumeration The order IS visible in the Trade Orders Window with status Open The order IS rendered on the chart What I have tried in the study code: Calling sc.CancelOrder(orderID) with the InternalOrderID I had recorded at submission time — appears to have no effect on phantom orders. Setting sc.FlagToReloadChartData = 1 after detecting the phantom condition for 10+ seconds — the chart reloads (the study re-initializes), but the phantom order remains visible afterward. Calling sc.FlattenAndCancelAllOrders() — has no effect on the phantom. Setting sc.MaintainTradeStatisticsAndTradesData = 1 to enable deep order lookup, then trying sc.GetOrderByOrderID(N) for various N — does not return the phantom either. What I am asking: Is there an ACSIL function or variable that performs the equivalent of Trade >> Refresh Trade Data From Service — i.e., requests a fresh order/position state from the connected Trading service and reconciles local state to match? I have not found one in the documentation. If no such function exists, what is the recommended way to handle this case from ACSIL? Specifically: how do I force Sierra Chart's local order tracker to drop an order that the broker no longer has, without disconnecting and reconnecting? Is the Pos.WorkingOrdersExist flag intended to be authoritative for the symbol/account specified in sc.GetTradePositionForSymbolAndAccount()? Today my logs show this flag stuck at 1 for over 3 hours after a trade closed cleanly, with no actual working orders for the symbol/account. If this is a known behavior, what is the recommended pattern for reliably detecting "I am flat with no working orders"? Is there any known interaction between Rithmic's "Order modification failed" responses and Sierra Chart's local order state where a Canceled order can be re-marked Open by Sierra in response to a broker echo? The trace above shows the order going Canceled then Open within 48 microseconds, with no additional action from my study between those events. Additional context: The study is running v4.19 with sc.UpdateAlways = 1 and a Chart Update Interval of 100ms. The chart is an Aligned Renko 20-tick chart on NQM6.CME with Trade and Current Quote Symbol set to MNQM6.CME, Use as Trade Only Symbol = Yes. Three instances of the study run on the same chart but only one is the master sweeper. Move-to-Breakeven (Native) is enabled. I have attached the full Trade Activity Log and Sierra Chart Message Log from today (2026-04-29) showing the incident at 09:57 if helpful. Thank you. |
Private File Private File |
