I found the very strange behaviour of DayOfWeek property.
When run the strategy with property of this type twice - it cruses NT.
I tested on 4 PCs: two crushed, another two worked fine.
Fully qualified name like System.DayOfWeek not helps.
What can be the reason?
namespace NinjaTrader.NinjaScript.Strategies.NT_Forum_Strategies
{
public class sDayOfWeed_Sa_Crush : Strategy
{
protected override void OnStateChange()
{
}
[NinjaScriptProperty]
[Display(Name="Period", GroupName="Parameters", Order=1)]
public
DayOfWeek
Period
{ get; set; }
}
}
The video (0:20): https://screencast-o-matic.com/watch/cYeZIgyuSn
There are 2 error messages in log:
1. Unhandled exception: Object reference not set to an instance of an object.
2. Unable to create instance of NinjaScript 'sDayOfWeed_Sa_Crush'. Most likely either the implementation no longer exists, there is no default constructor defined, the default constructor does not work correctly, or the 'OnStateChange' implementation for State=SetDefaults is flawed: System.NullReferenceException: Object reference not set to an instance of an object.
Trace file:
2020-03-24 16:05:23:570 Starting server message polling timer with interval 3600 seconds...
2020-03-24 16:06:59:018 ERROR: Unable to create instance of NinjaScript 'sDayOfWeed_Sa_Crush'. Most likely either the implementation no longer exists, there is no default constructor defined, the default constructor does not work correctly, or the 'OnStateChange' implementation for State=SetDefaults is flawed: System.NullReferenceException: Object reference not set to an instance of an object. at NinjaTrader.NinjaScript.Parameter.CopyTo(Parameter parameter) at NinjaTrader.NinjaScript.Parameter.Clone() at NinjaTrader.NinjaScript.StrategyBase.CopyTo(NinjaS cript ninjaScript) at NinjaTrader.Gui.NinjaScript.StrategyRenderBase.Cop yTo(NinjaScript ninjaScript) at NinjaTrader.NinjaScript.NinjaScript.Clone()
2020-03-24 16:06:59:027 *************** unhandled exception trapped ***************
2020-03-24 16:06:59:027 Object reference not set to an instance of an object.
2020-03-24 16:06:59:028 System.NullReferenceException: Object reference not set to an instance of an object.
at NinjaTrader.NinjaScript.Parameter.CopyTo(Parameter parameter)
at NinjaTrader.Gui.NinjaScript.StrategyTemplate.Apply StrategyParameters(StrategyBase template, StrategyBase target, Boolean allParams)
at NinjaTrader.Gui.NinjaScript.StrategyAnalyzer.Strat egyAnalyzerViewModel.<>c__DisplayClass89_0.<OnRunC ompleted>g__Done|1(Boolean playSound)
at NinjaTrader.Gui.NinjaScript.StrategyAnalyzer.Strat egyAnalyzerViewModel.<>c__DisplayClass89_0.<OnRunC ompleted>b__0()
at System.Windows.Threading.DispatcherOperation.Invok eDelegateCore()
at System.Windows.Threading.DispatcherOperation.Invok eImpl()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatch Info.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.Handle NonSuccessAndDebuggerNotification(Task task)
at System.Windows.Threading.DispatcherOperation.Wait( TimeSpan timeout)
at System.Windows.Threading.Dispatcher.InvokeImpl(Dis patcherOperation operation, CancellationToken cancellationToken, TimeSpan timeout)
at System.Windows.Threading.Dispatcher.Invoke(Action callback, DispatcherPriority priority, CancellationToken cancellationToken, TimeSpan timeout)
at System.Windows.Threading.Dispatcher.Invoke(Action callback)
at NinjaTrader.Gui.Tools.DispatcherHelper.CheckUiInvo ke(Dispatcher uiDispatcher, Action action, Boolean async)
at NinjaTrader.Gui.NinjaScript.StrategyAnalyzer.Strat egyAnalyzerViewModel.DispatchToOwner(Action action)
at NinjaTrader.Gui.NinjaScript.StrategyAnalyzer.Strat egyAnalyzerViewModel.OnRunCompleted(StrategyAnalyz erTabControl tab, LogSourceFileInfo nsLogSource, RunResult result)
at NinjaTrader.Gui.NinjaScript.StrategyAnalyzer.Strat egyAnalyzerViewModel.<>c__DisplayClass88_0.<OnRun> b__1(RunResult r)
at NinjaTrader.Gui.NinjaScript.StrategyAnalyzer.Strat egyRunner.<>c__DisplayClass7_0.<RunStrategyAsync>b __0(Object o)
at System.Threading.ExecutionContext.RunInternal(Exec utionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.ExecutionContext.Run(ExecutionCon text executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
at System.Threading.QueueUserWorkItemCallback.System. Threading.IThreadPoolWorkItem.ExecuteWorkItem()
at System.Threading.ThreadPoolWorkQueue.Dispatch()
Log:
2020-03-24 16:06:59:018|3|4|Unable to create instance of NinjaScript 'sDayOfWeed_Sa_Crush'. Most likely either the implementation no longer exists, there is no default constructor defined, the default constructor does not work correctly, or the 'OnStateChange' implementation for State=SetDefaults is flawed: System.NullReferenceException: Object reference not set to an instance of an object. at NinjaTrader.NinjaScript.Parameter.CopyTo(Parameter parameter) at NinjaTrader.NinjaScript.Parameter.Clone() at NinjaTrader.NinjaScript.StrategyBase.CopyTo(NinjaS cript ninjaScript) at NinjaTrader.Gui.NinjaScript.StrategyRenderBase.Cop yTo(NinjaScript ninjaScript) at NinjaTrader.NinjaScript.NinjaScript.Clone()
2020-03-24 16:06:59:028|0|4|Unhandled exception: Object reference not set to an instance of an object.
Comment