I created a simple indicator that has buy/sell buttons to place pending orders.
The indicator works perfectly on sim account, but when i change the account from the chart trader, the script stops working.
In the SetDefaults i search for the Sim account :
lock (Account.All)
myAccount = Account.All.FirstOrDefault(a => a.Name == "Sim101");
ChartControl.Dispatcher.InvokeAsync((Action)(() =>
{
xAlselector = Window.GetWindow(ChartControl.Parent).FindFirst("ChartTraderControlAccountSelector") as NinjaTrader.Gui.Tools.AccountSelector;
AccName = xAlselector.SelectedAccount.Name;
}));
After that, i want to place my pending order :
TriggerCustomEvent(o =>
{
//Order stopOrder = null;
longOrder = myAccount.CreateOrder(Instrument,
OrderAction.Buy,
OrderType.StopMarket,
TimeInForce.Day,
nContractQuantity,
0,
longprice,
string.Empty,
"Entry",
null);
// Submits our entry order with the ATM strategy named "myAtmStrategyName"
NinjaTrader.NinjaScript.AtmStrategy.StartAtmStrategy(AtmStrategyName1, longOrder);
myAccount.Submit(new[] { longOrder });
}, null);
It is all working well on the Sim account, however i have a feeling that the myAccount variable is still on the Sim and does not update when I change the account from the chart trader.
If this is the case, how can i set the myAccount variable to the correct account?
Thank you very much

Comment