I have a problem with my code which works very well on Sim account. It bug with an LL account (Leeloo connected to Ritmic)
I get an error message : Unhandled exception
After research, the following instruction is the problem: Acct.Positions.Count
Thanks for your help.
My code is :
protected void Button1Click(object sender, RoutedEventArgs e)
{
xAlselector = Window.GetWindow(ChartControl.Parent).FindFirst("C hartTraderControlAccountSelector") as NinjaTrader.Gui.Tools.AccountSelector;
quantitySelector = Window.GetWindow(ChartControl.Parent).FindFirst("C hartTraderControlQuantitySelector") as NinjaTrader.Gui.Tools.QuantityUpDown;
Account Acct = Account.All.FirstOrDefault(x => x.Name == xAlselector.SelectedAccount.ToString());
if (Acct.Positions.Count>=0) { OpenBuy(quantitySelector.Value); /*for (int n=1; n<=quantitySelector.Value; n++) AddStopLoss(1);*/ return;}
else {DisplayInfo("Not Possible because Position Already Open !!!",Brushes.Red); return;}
}

Comment