I've created an indicator with a button, so that I can enable that strategy with the button (instead of going into the strategies dialog every time). However, I cannot figure out how to enable the strategy from within my NinjaScript code. In fact, I can only get a reference to the strategy if it is already enabled on the account. Is there a way to accomplish this?
Here is the code snippet where I am trying to accomplish this:
private void enableKingJTrader(object sender, RoutedEventArgs e) {
Print("Enabling King J Trader");
NinjaTrader.Gui.Tools.AccountSelector xAlselector;
bool kingJStratEnabled = false;
ChartControl.Dispatcher.InvokeAsync((Action)(() =>
{
xAlselector = Window.GetWindow(ChartControl.Parent).FindFirst("C hartTraderControlAccountSelector") as NinjaTrader.Gui.Tools.AccountSelector;
Print(xAlselector.SelectedAccount.ToString());
foreach (StrategyBase strat in xAlselector.SelectedAccount.Strategies) {
Print("In a Strat");
Print(strat.Name);
if (strat.Name == "KingJ Zone Scale") {
kingJStratEnabled = true;
}
}
if (kingJStratEnabled == false) {
//SOMEHOW ENABLE THE STRATEGY I WANT
}
}));
}

Comment