I did an old algorithm, that uses "unmanaged approach" from NT7 and never had any issues regarding orders, live or simulated. After transitioning to NT8 and rewriting it accordingly, I decided to do some tests, first under simulation, which has been running for several days and all seems right. Every day, I start the algo at 6:00pm, so all data is real-time until 5:00pm next day. Today, the first weird issue: the Algorithm submitted an order at 08:02 am, but this remained unfilled cause the market moved. The order kept working and finally at 08:40 am, the order finally got filled, but after that, the I get the weird message
"2023-11-17 08:40:45:346|0|4|Strategy 'XXXYYY' has been disabled because it attempted to modify a historical order that has transitioned to a live order. Please see the help guide for more information on transitioning order references from historical to live.
So, since it makes no sense cause all data has been real-time and not historical, I can't understand. So I pulled out the LOG and TRACE info regarding this issue, so you can take a quick look right away:
2023-11-17 08:02:47:331|1|32|Order='da15fe4022194b19b6bfc03dc d6c453e/Sim101' Name='SET LONG' New state='Submitted' Instrument='MES DEC23' Action='Buy' Limit price=4534 Stop price=0 Quantity=1 Type='Limit' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
2023-11-17 08:02:47:473|1|32|Order='da15fe4022194b19b6bfc03dc d6c453e/Sim101' Name='SET LONG' New state='Accepted' Instrument='MES DEC23' Action='Buy' Limit price=4534 Stop price=0 Quantity=1 Type='Limit' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
2023-11-17 08:02:47:475|1|32|Order='da15fe4022194b19b6bfc03dc d6c453e/Sim101' Name='SET LONG' New state='Working' Instrument='MES DEC23' Action='Buy' Limit price=4534 Stop price=0 Quantity=1 Type='Limit' Time in force=GTC Oco='' Filled=0 Fill price=0 Error='No error' Native error=''
2023-11-17 08:40:45:268|1|32|Order='da15fe4022194b19b6bfc03dc d6c453e/Sim101' Name='SET LONG' New state='Filled' Instrument='MES DEC23' Action='Buy' Limit price=4534 Stop price=0 Quantity=1 Type='Limit' Time in force=GTC Oco='' Filled=1 Fill price=4534 Error='No error' Native error=''
2023-11-17 08:40:45:276|1|8|Execution='5d9c1e11b22c43f1b1645a f4e1a3fecb' Instrument='MES DEC23' Account='Sim101' Exchange=Default Price=4534 Quantity=1 Market position=Long Operation=Operation_Add Order='da15fe4022194b19b6bfc03dcd6c453e' Time='11/17/2023 8:40 AM'
2023-11-17 08:40:45:343|1|64|Instrument='MES DEC23' Account='Sim101' Average price=4534 Quantity=1 Market position=Long Operation=Operation_Add
2023-11-17 08:40:45:346|0|4|Strategy 'RCS/311242239' has been disabled because it attempted to modify a historical order that has transitioned to a live order. Please see the help guide for more information on transitioning order references from historical to live.
TRACE
2023-11-17 08:02:47:149 (IBpiers) Cbi.Account.CreateOrder: orderId='da15fe4022194b19b6bfc03dcd6c453e' account='Sim101' name='SET LONG' orderState=Initialized instrument='MES DEC23' orderAction=Buy orderType='Limit' limitPrice=4534 stopPrice=0 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=70 time='2023-11-17 08:02:47' gtd='2099-12-01' statementDate='2023-11-17' id=-1 comment=''
2023-11-17 08:02:47:157 (IBpiers) Cbi.Account.Submit0: realOrderState=Initialized isPendingSubmit=False orderId='da15fe4022194b19b6bfc03dcd6c453e' account='Sim101' name='SET LONG' orderState=Initialized instrument='MES DEC23' orderAction=Buy orderType='Limit' limitPrice=4534 stopPrice=0 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=70 time='2023-11-17 08:02:47' gtd='2099-12-01' statementDate='2023-11-17'
2023-11-17 08:02:47:162 (IBpiers) Cbi.Account.Submit1: realOrderState=Initialized orderId='da15fe4022194b19b6bfc03dcd6c453e' account='Sim101' name='SET LONG' orderState=Initialized instrument='MES DEC23' orderAction=Buy orderType='Limit' limitPrice=4534 stopPrice=0 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=70 time='2023-11-17 08:02:47' gtd='2099-12-01' statementDate='2023-11-17'
2023-11-17 08:02:47:164 (IBpiers) Cbi.Simulator.Submit: realOrderState=Initialized orderId='da15fe4022194b19b6bfc03dcd6c453e' account='Sim101' name='SET LONG' orderState=Submitted instrument='MES DEC23' orderAction=Buy orderType='Limit' limitPrice=4534 stopPrice=0 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=70 time='2023-11-17 08:02:47' gtd='2099-12-01' statementDate='2023-11-17' delay=100
2023-11-17 08:02:47:165 (IBpiers) Cbi.Account.OrderUpdateCallback: realOrderState=Submitted orderId='da15fe4022194b19b6bfc03dcd6c453e' account='Sim101' name='SET LONG' orderState=Submitted instrument='MES DEC23' orderAction=Buy limitPrice=4534 stopPrice=0 quantity=1 orderType='Limit' filled=0 averageFillPrice=0 time='2023-11-17 08:02:47' statementDate='2023-11-17' error=NoError comment='' nr=-1
2023-11-17 08:02:47:473 (IBpiers) Cbi.Account.OrderUpdateCallback: realOrderState=Accepted orderId='da15fe4022194b19b6bfc03dcd6c453e' account='Sim101' name='SET LONG' orderState=Accepted instrument='MES DEC23' orderAction=Buy limitPrice=4534 stopPrice=0 quantity=1 orderType='Limit' filled=0 averageFillPrice=0 time='2023-11-17 08:02:47' statementDate='2023-11-17' error=NoError comment='' nr=-1
2023-11-17 08:02:47:474 (IBpiers) Cbi.Account.OrderUpdateCallback: realOrderState=Working orderId='da15fe4022194b19b6bfc03dcd6c453e' account='Sim101' name='SET LONG' orderState=Working instrument='MES DEC23' orderAction=Buy limitPrice=4534 stopPrice=0 quantity=1 orderType='Limit' filled=0 averageFillPrice=0 time='2023-11-17 08:02:47' statementDate='2023-11-17' error=NoError comment='' nr=-1
2023-11-17 08:02:47:772 (IBpiers) Cbi.Account.Change0: realOrderState=Working orderId='da15fe4022194b19b6bfc03dcd6c453e' account='Sim101' name='SET LONG' orderState=Working instrument='MES DEC23' orderAction=Buy orderType='Limit' limitPrice=4534 stopPrice=0 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=70 time='2023-11-17 08:02:47' gtd='2099-12-01' statementDate='2023-11-17' limitPriceChanged=4534 stopPriceChanged=0 quantityChanged=1
2023-11-17 08:40:45:128 (IBpiers) Cbi.Simulator.Fill1: realOrderState=Working orderId='da15fe4022194b19b6bfc03dcd6c453e' maxFillQuantity=1 price=4534 thread=39
2023-11-17 08:40:45:128 (IBpiers) Cbi.Simulator.Fill2: realOrderState=Working orderId='da15fe4022194b19b6bfc03dcd6c453e' fillQuantity=1 price=4534
2023-11-17 08:40:45:131 (IBpiers) Cbi.Account.OrderUpdateCallback: realOrderState=Filled orderId='da15fe4022194b19b6bfc03dcd6c453e' account='Sim101' name='SET LONG' orderState=Filled instrument='MES DEC23' orderAction=Buy limitPrice=4534 stopPrice=0 quantity=1 orderType='Limit' filled=1 averageFillPrice=4534 time='2023-11-17 08:40:45' statementDate='2023-11-17' error=NoError comment='' nr=-1
2023-11-17 08:40:45:275 (IBpiers) Cbi.Account.ExecutionUpdateCallback: executionId='5d9c1e11b22c43f1b1645af4e1a3fecb' account='Sim101' instrument='MES DEC23' exchange=Globex price=4534 quantity=1 marketPosition=Long operation=Add orderID='da15fe4022194b19b6bfc03dcd6c453e' isSod=False time='2023-11-17 08:40:45' statementDate='2023-11-17'
2023-11-17 08:40:45:342 (IBpiers) Cbi.Account.PositionUpdateCallback: instrument='MES DEC23' account='Sim101' avgPrice=4534 quantity=1 marketPosition=Long operation=Add
2023-11-17 08:40:45:355 NinjaScript.StrategyBase.CancelAllOrders: orderId='9fe8d36f9c1246d6b0dc8c03cce39572' account='Sim101' name='LONG STOPLOSS' orderState=Accepted instrument='MES DEC23' orderAction=Sell orderType='Stop Limit' limitPrice=4421.75 stopPrice=4426.75 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=69 time='2023-11-16 17:10:41' gtd='2099-12-01' statementDate='2023-11-16'
2023-11-17 08:40:45:356 (IBpiers) Cbi.Account.Cancel0: realOrderState=Accepted orderId='9fe8d36f9c1246d6b0dc8c03cce39572' account='Sim101' name='LONG STOPLOSS' orderState=CancelPending instrument='MES DEC23' orderAction=Sell orderType='Stop Limit' limitPrice=4421.75 stopPrice=4426.75 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=69 time='2023-11-17 08:40:45' gtd='2099-12-01' statementDate='2023-11-17'
2023-11-17 08:40:45:356 (IBpiers) Cbi.Account.OrderUpdateCallback: realOrderState=CancelPending orderId='9fe8d36f9c1246d6b0dc8c03cce39572' account='Sim101' name='LONG STOPLOSS' orderState=CancelPending instrument='MES DEC23' orderAction=Sell limitPrice=4421.75 stopPrice=4426.75 quantity=1 orderType='Stop Limit' filled=0 averageFillPrice=0 time='2023-11-17 08:40:45' statementDate='2023-11-17' error=NoError comment='' nr=-1
2023-11-17 08:40:45:356 (IBpiers) Cbi.Account.Cancel1: realOrderState=CancelPending orderId='9fe8d36f9c1246d6b0dc8c03cce39572' account='Sim101' name='LONG STOPLOSS' orderState=CancelPending instrument='MES DEC23' orderAction=Sell orderType='Stop Limit' limitPrice=4421.75 stopPrice=4426.75 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=69 time='2023-11-17 08:40:45' gtd='2099-12-01' statementDate='2023-11-17'
2023-11-17 08:40:45:358 (IBpiers) Cbi.Simulator.Cancel: realOrderState=CancelPending orderId='9fe8d36f9c1246d6b0dc8c03cce39572' account='Sim101' name='LONG STOPLOSS' orderState=CancelSubmitted instrument='MES DEC23' orderAction=Sell orderType='Stop Limit' limitPrice=4421.75 stopPrice=4426.75 quantity=1 tif=Gtc oco='' filled=0 averageFillPrice=0 onBehalfOf='' id=69 time='2023-11-17 08:40:45' gtd='2099-12-01' statementDate='2023-11-17' delay=100
2023-11-17 08:40:45:358 (IBpiers) Cbi.Account.OrderUpdateCallback: realOrderState=CancelSubmitted orderId='9fe8d36f9c1246d6b0dc8c03cce39572' account='Sim101' name='LONG STOPLOSS' orderState=CancelSubmitted instrument='MES DEC23' orderAction=Sell limitPrice=4421.75 stopPrice=4426.75 quantity=1 orderType='Stop Limit' filled=0 averageFillPrice=0 time='2023-11-17 08:40:45' statementDate='2023-11-17' error=NoError comment='' nr=-1
2023-11-17 08:40:45:506 (IBpiers) Cbi.Account.OrderUpdateCallback: realOrderState=Cancelled orderId='9fe8d36f9c1246d6b0dc8c03cce39572' account='Sim101' name='LONG STOPLOSS' orderState=Cancelled instrument='MES DEC23' orderAction=Sell limitPrice=4421.75 stopPrice=4426.75 quantity=1 orderType='Stop Limit' filled=0 averageFillPrice=0 time='2023-11-17 08:40:45' statementDate='2023-11-17' error=NoError comment='' nr=5
This should be done in OnOrderUpdate() to ensure all cases of order transitions are handled.
| Critical: If you DO NOT update a historical order reference, and then attempt to cancel/change that order after it has been submitted in real-time, your strategy will be disabled with a message similar to: "Strategy has been disabled because it attempted to modify a historical order that has transitioned to a live order." |
| Tip: When the real-time order is submitted, there is a generic Order object passed into the OnOrderUpdate() method containing the live order details which can be used for debugging. It is recommended you use the helper GetRealtimeOrder() when your strategy transitions to real-time to update your order references |
- Can you give an example, how in NT8, should be updated the state of an order? I did it exactly like NT7 and it has worked so far.
- Please, advise if I must use an additional method to OnOrderUpdate.
Thanks

Comment