Task: reconnect to the open position after re-open the strategy
Steps:
1. the strategy is enabled.
2. the strategy to open the position.
3. manual shutdown of the strategy(a stress test, it may be shut down after exception).
4. the position remains open.
5. reconnection the strategy from code.
6. the strategy enabled. the position is still open.
7. access to the position from the strategy is limited.
8. tracing writes there is no exit to the position.
9. orders are present in the table.
Goal: how to access the open position data from a re-enabled strategy?
************************************************** ********************************
used:
...
lock (NinjaTrader.Cbi.Account.All) myAccount = NinjaTrader.Cbi.Account.All.FirstOrDefault(a => a.Name == "Sim101");
...
foreach(var posa in myAccount.Positions)
{
if(posa.Instrument.MasterInstrument.Name.Equals(ticker))
{
if(posa.MarketPosition == MarketPosition.Long)
{
ExitLong(close, open);// order sent but without target goal
}
//if to used Position.MarketPosition, market position after reconnect always FLAT.

Comment