I'm attempting to use the ChartTrader and AtmStrategySelector to let a user running my strategy select an ATM from the chart trader and my strategy to open and manage a trade with the ATM. The first step in this is capturing the name of the ATM currently selected in the ChartTrader.
Here's the interesting part. The code below is only able to report names of ATMs I created in NT7 and were imported in the upgrade process. ATMs I created with NT8 don't work. They always return the name 'ATMStrategy'. Additionally, the id is always -1 regardless if it is returning the correct name.
To see the results I put a call to the code below in OnBarUpate and look at the output window.
Any feedback or input on getting this right is much appreciated.
protected bool UseATM() { try { //Dispatcher used to Assure Executed on UI Thread this.Dispatcher.Invoke((Action)(() => { chartTrader = Window.GetWindow(ChartControl.Parent).FindFirst("ChartWindowChartTraderControl") as ChartTrader; NinjaTrader.Gui.NinjaScript.AtmStrategy.AtmStrategySelector selector = chartTrader.FindFirst("ChartTraderControlATMStrategySelector") as NinjaTrader.Gui.NinjaScript.AtmStrategy.AtmStrategySelector; Print("SelectedAtmStrategy: " + selector.SelectedItem.ToString()); })); return true; } catch (Exception ex) { Print("UseATM: " + ex.Message.ToString()); return false; } }
Comment