Strategy uses List<> in params and fails.
1) Add to the chart
2) Recompile
3) Update/F5 and get fatal error with removing from the chart
It's very unsuitable that strategy is removing from the chart
Error is
Error on getting/setting property 'ListCollection' for NinjaScript 'ListCollectionStrategy': Object of type 'System.Collections.Generic.List`1[NinjaTrader.NinjaScript.Strategies.TestUtils.Condi tionOption]' cannot be converted to type 'System.Collections.Generic.List`1[NinjaTrader.NinjaScript.Strategies.TestUtils.Condi tionOption]'.
Then base.CopyTo generates 'BarsRequiredToTrade' cannot be set from this state. Please see the Help Guide article on 'BarsRequiredToTrade' for more information.
Then I see message box with the error of setting parameter "IncludeTestHistoryInBacktest"
I use example from Drawing tools that uses reflection, but it fails
Trace error
2021-12-08 17:03:08:849 *************** unhandled exception trapped *************** 2021-12-08 17:03:08:849 'IncludeTradeHistoryInBacktest' cannot be set from this state. Please see the Help Guide article on 'IncludeTradeHistoryInBacktest' for more information. 2021-12-08 17:03:08:850 System.InvalidOperationException: 'IncludeTradeHistoryInBacktest' cannot be set from this state. Please see the Help Guide article on 'IncludeTradeHistoryInBacktest' for more information. at NinjaTrader.NinjaScript.StrategyBase.set_IncludeTr adeHistoryInBacktest(Boolean value) at NinjaTrader.NinjaScript.StrategyBase.CreateNewGene ration(Boolean copyOrdersAndExecutions, Nullable`1 includeTradeHistoryInBacktest) at NinjaTrader.Gui.Chart.ChartControl.StrategyEnable( StrategyRenderBase strategy, ChartBars cb, Boolean isAdded, Action`1 errorOnEnableCallback) at NinjaTrader.Gui.Chart.ChartControl.ApplyStrategy(S trategyRenderBase originalStrategy, StrategyRenderBase strategy, ChartBars cb, Boolean isAdded, Action`1 errorOnEnableCallback) at NinjaTrader.Gui.Chart.ChartCommands.ReloadNinjaScr iptExecuted(Object sender, ExecutedRoutedEventArgs e) at System.Windows.Input.CommandBinding.OnExecuted(Obj ect sender, ExecutedRoutedEventArgs e) at System.Windows.Input.CommandManager.ExecuteCommand Binding(Object sender, ExecutedRoutedEventArgs e, CommandBinding commandBinding) at System.Windows.Input.CommandManager.FindCommandBin ding(CommandBindingCollection commandBindings, Object sender, RoutedEventArgs e, ICommand command, Boolean execute) at System.Windows.Input.CommandManager.FindCommandBin ding(Object sender, RoutedEventArgs e, ICommand command, Boolean execute) at System.Windows.Input.CommandManager.OnExecuted(Obj ect sender, ExecutedRoutedEventArgs e) at System.Windows.RoutedEventArgs.InvokeHandler(Deleg ate handler, Object target) at System.Windows.RoutedEventHandlerInfo.InvokeHandle r(Object target, RoutedEventArgs routedEventArgs) at System.Windows.EventRoute.InvokeHandlersImpl(Objec t source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.RaiseEventImpl(Dependency Object sender, RoutedEventArgs args) at System.Windows.Input.RoutedCommand.ExecuteImpl(Obj ect parameter, IInputElement target, Boolean userInitiated) at NinjaTrader.Gui.Chart.ChartControl.<>c.<.ctor>b__3 92_5(Object s, EventArgs e, ICommand c) at NinjaTrader.Gui.Chart.ChartControl.OnReloadNinjaSc riptHotKey(Object sender, KeyEventArgs e) at NinjaTrader.Gui.HotKeys.HotKeysManager.TryChartHot Key(Object sender, KeyEventArgs e, IInputElement senderWindow, IInputElement ownerWindow) at NinjaTrader.Gui.HotKeys.HotKeysManager.OnPreviewKe yDown(Object sender, KeyEventArgs e) at System.Windows.RoutedEventArgs.InvokeHandler(Deleg ate handler, Object target) at System.Windows.RoutedEventHandlerInfo.InvokeHandle r(Object target, RoutedEventArgs routedEventArgs) at System.Windows.EventRoute.InvokeHandlersImpl(Objec t source, RoutedEventArgs args, Boolean reRaised) at System.Windows.UIElement.RaiseEventImpl(Dependency Object sender, RoutedEventArgs args) at System.Windows.UIElement.RaiseTrustedEvent(RoutedE ventArgs args) at System.Windows.Input.InputManager.ProcessStagingAr ea() at System.Windows.Input.InputManager.ProcessInput(Inp utEventArgs input) at System.Windows.Input.InputProviderSite.ReportInput (InputReport inputReport) at System.Windows.Interop.HwndKeyboardInputProvider.R eportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawKeyboardActions actions, Int32 scanCode, Boolean isExtendedKey, Boolean isSystemKey, Int32 virtualKey) at System.Windows.Interop.HwndKeyboardInputProvider.P rocessKeyAction(MSG& msg, Boolean& handled) at System.Windows.Interop.HwndSource.CriticalTranslat eAccelerator(MSG& msg, ModifierKeys modifiers) at System.Windows.Interop.HwndSource.OnPreprocessMess age(Object param) at System.Windows.Threading.ExceptionWrapper.Internal RealCall(Delegate callback, Object args, Int32 numArgs) at System.Windows.Threading.ExceptionWrapper.TryCatch When(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
ListCollectionStrategy.cs
With best regards,
Comment