}
else if (State == State.DataLoaded)
{
lock (Account.All)
myAccount = Account.All.FirstOrDefault(a => a.Name == "Sim101");
if (myAccount != null)
myAccount.PositionUpdate += MyAccount_PositionUpdate;
}
else if (State == State.Terminated)
{
if (myAccount != null)
myAccount.PositionUpdate -= MyAccount_PositionUpdate;
}
}
private void MyAccount_PositionUpdate(object sender, PositionEventArgs e)
{
//Code
marketPos = System.Convert.ToInt32(e.MarketPosition);
Print(marketPos);
}
When the account is Long, Flat, and Short the outputs are, respectively:
Sim101: 0, 2, 1
Cash: 0, 1, 1
Any clue what's going on here? Why do the outputs change depending on which account I'm using? This discrepancy prevents my program from properly identifying what my accounts' true position is without otherwise superfluous code. Any help would be greatly appreciated!
Thank you in advance NinjaTrader Community

Comment