Unmanaged Approach, nulling orders

I’m having some trouble with nulling an order object. Here the order entry is linked with a ref to null primary1EntryShort.

		if (sumFilled == expectedQuantity)
		{
			PrintIf($"		↳ ✅ COMPLETE");
			sumFilledValue = 0;
			entry = null;
			expectedQuantity = 0;
			PrintIf($"entry = {entry}");
			PrintIf($"primary1EntryShort = {primary1EntryShort}");
		}

This is in OnExecutionUpdate, and primary1EntryShort is null here (so the ref is working), when the order is fully filled. But immediately on the next bar the order object comes back and it’s not null:

↳ ✅ COMPLETE
entry =  // Null
primary1EntryShort = // Null 
=======
// Next Tick
primary1EntryShort = orderId='5036fe466f58401d96e945da54db541d' account='Playback101' name='Primary1Short' orderState=Filled instrument='ES JUN26' orderAction=SellShort orderType='Market' limitPrice=0 stopPrice=0 quantity=1 tif=Gtc oco='' filled=1 averageFillPrice=6741.5 onBehalfOf='' id=294 time='2026-03-18 10:12:48' gtd='2099-12-01' statementDate='2026-03-18'

There is zero code between these 2 things, OnOrderUpdate doesn’t fire, OnEexecution Update doesn’t fire. Nothing…The order just seems to come back on its own and I have no idea why.

Is there some known issues with nulling orders with the unmanaged approach?

ok, I figured it out. On the documentation it shows 2 ways of calling SubmitOrderUnmanaged but doesn’t really explain when to use either;

entryOrder = SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.Limit, 1, GetCurrentBid(), 0, "", "Long Limit");

and

SubmitOrderUnmanaged(0, OrderAction.Buy, OrderType.Market, 1, 0, 0, "", "Enter Long");

I was using the first method, and for Market orders it doesn’t allow the order object to be nulled within OnExecutionUpdate. Only after the entire process is complete.

1 Like