Struggling with Account.Flatten in unmanaged mode

Hi

I’m having problems with Account.Flatten in my ‘unmanaged’ strategy in that it is terminating the strategy. Is there anything I can do that will keep my code alive?

I’m executing this:

Account.Flatten(new { Instrument });

Thanks for any help you can give.

PS. I’m unsure why [ and ] are being converted to a box!

I could be wrong but my view is that Flatten mimicks the pressing of the Close button in ChartTrader which is why your strategy unloads.

Instead detect position side and Sell/Buy Position.Quantity accordingly

Yeah, that’s what I’ve ended up doing. Not my preferred solution as I have to cater for partial fills, rather than just issue an instruction.

I don’t understand how would Account.Position not take into consideration partial fills?

In my experience the quantity for Buy/Sell doesn’t always get filled as a whole when i do SubmitOrderUnmanaged so I have code that keeps checking and sweeps up and quantity not filled the first time round.