Get Open/Existing Positions When Strategy Starts

How can I collect the information about already opened positions when a strategy starts? I have this code in OnStartUp() but it returns always Quantity=0 and Position=Flat.

    private void onStartUpHandler()
    {
        int initQuantity            = Position.Quantity;
        MarketPosition initPosition = Position.MarketPosition;
    ....
    }

I have set under Tools | Options | Strategies the below settings. Changing “On starting a real-time strategy” didn’t change the result. The same for the Sim101 and the real account. In the Control Center under Positions I see the positions.

Please advice what I am doing wrong, how to get the data of the open strategies.

Under “ATM Strategy” all 3 options [Modify inner/nearest bracket and Use last price for auto trail…" are checked]. I can’t post more than 1 image.

Position is the strategy’s own position, not the account’s. At startup it only reflects trades the strategy made while processing history, so it reads Flat even when the account is long. For the real account position, read Account.Positions once the strategy is in State.Realtime, e.g. Account.Positions.FirstOrDefault(p => p.Instrument == Instrument), and use p.Quantity and p.MarketPosition. If you want the strategy to take over that position, set IsAdoptAccountPositionAware to true and pick the Start behavior ‘Adopt account position’; then Position matches the account. Also, NT8 has no OnStartUp(): put startup code in OnStateChange under State.DataLoaded or State.Realtime. Happy to help further, feel free to DM me.