Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

NT8 - unhandled Exception 'BarsRequiredToTrade' cannot be set from this state.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    NT8 - unhandled Exception 'BarsRequiredToTrade' cannot be set from this state.

    ok so i tried to autostart the strategy in the constructor :-)
    i toll the code out again... NT8 crashed out on this one

    2015-05-12 10:54:31:099 ERROR: Error on getting/setting property 'BarsRequiredToTrade' for NinjaScript 'MicroTrends USAR Trader': Exception has been thrown by the target of an invocation.
    2015-05-12 10:54:31:133 *************** unhandled exception trapped ***************
    2015-05-12 10:54:31:133 'BarsRequiredToTrade' cannot be set from this state. Please see the Help Guide article on 'BarsRequiredToTrade' for more information.
    2015-05-12 10:54:31:166 System.InvalidOperationException: 'BarsRequiredToTrade' cannot be set from this state. Please see the Help Guide article on 'BarsRequiredToTrade' for more information.
    at NinjaTrader.NinjaScript.StrategyBase.set_BarsRequi redToTrade(Int32 value)
    at NinjaTrader.NinjaScript.StrategyBase.CopyTo(NinjaS cript ninjaScript)
    at NinjaTrader.NinjaScript.NinjaScript.Clone()
    at NinjaTrader.Gui.NinjaScript.StrategyAnalyzer.Strat egyAnalyzerViewModel.<OnRecompile>b__34()
    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.CompilerServices.TaskAwaiter.ThrowF orNonSuccess(Task task)
    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.OnRecompile(Object sender, EventArgs e)
    at System.EventHandler.Invoke(Object sender, EventArgs e)
    at NinjaTrader.Code.Compiler.Compile(Boolean checkCompileOnly, Boolean debugBuild, IEnumerable`1 filesToIgnore, IEnumerable`1 filesInTmp)
    at NinjaTrader.Gui.NinjaScript.Editor.EditorViewModel .<>c__DisplayClass8c.<OnCompile>b__86(Object s)
    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()
    2015-05-12 10:54:31:167 ERROR: There are no email share services defined. You need to define one and set "Default" to true for email to work.
    MicroTrends
    NinjaTrader Ecosystem Vendor - micro-trends.co.uk

    #2
    which led to:
    2015-05-12 10:54:56:954 ERROR: Strategy '42302435': unable to deserialize user data: There is an error in XML document (22, 4).
    2015-05-12 10:55:03:584 *************** unhandled exception trapped ***************
    2015-05-12 10:55:03:584 Exception has been thrown by the target of an invocation.
    2015-05-12 10:55:03:588 System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.Data.SqlServerCe.SqlCeException: Either the cursor is not on a row or there are no rows left.
    at System.Data.SqlServerCe.Accessor.get_Value()
    at System.Data.SqlServerCe.SqlCeDataReader.FetchValue (Int32 index)
    at System.Data.SqlServerCe.SqlCeDataReader.IsDBNull(I nt32 ordinal)
    at System.Data.SqlServerCe.SqlCeDataReader.GetValue(I nt32 ordinal)
    at NinjaTrader.Cbi.Execution.DbGetExecutions1(IDbComm and cmd)
    at NinjaTrader.Cbi.Execution.DbGet(Account account, Instrument instrument, DateTime minTime, DateTime maxTime)
    at NinjaTrader.Gui.Chart.ChartBars.LoadExecutionsByAc count(ChartBars chartBars, Account account, ChartControl chartControl)
    at NinjaTrader.Gui.Chart.ChartBars.CollectExecutions( ChartControl chartControl)
    at NinjaTrader.Gui.Chart.ChartControl.<>c__DisplayCla ss1a9.<OnGetBarsCallback>b__1a2(Bars bars, ChartControl chartControl, ChartBars chartBars2)
    --- End of inner exception stack trace ---
    at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
    at System.Reflection.RuntimeMethodInfo.UnsafeInvokeIn ternal(Object obj, Object[] parameters, Object[] arguments)
    at System.Delegate.DynamicInvokeImpl(Object[] args)
    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)
    MicroTrends
    NinjaTrader Ecosystem Vendor - micro-trends.co.uk

    Comment


      #3
      Hello,

      Thank you for sharing this with us. When you say that you tried to autostart the strategy in the constructor, can you please clarify exactly what you tried? Were you doing something like the following?

      Code:
       public class MyCustomStrategy2 : Strategy
       { 
        public MyCustomStrategy2()
        {
         this.IsEnabled = true;
        }
      Also, were you setting BarsRequiredToTrade in your code? If so, can you please tell me which State you were calling it in within OnStateChange()?
      Dave I.NinjaTrader Product Management

      Comment


        #4
        Originally posted by NinjaTrader_Dave View Post
        Hello,

        Thank you for sharing this with us. When you say that you tried to autostart the strategy in the constructor, can you please clarify exactly what you tried? Were you doing something like the following?

        Code:
         public class MyCustomStrategy2 : Strategy
         { 
          public MyCustomStrategy2()
          {
           this.IsEnabled = true;
          }
        Also, were you setting BarsRequiredToTrade in your code? If so, can you please tell me which State you were calling it in within OnStateChange()?
        aha IsEnabled!!! Cool i had overlooked that property and tried to set the state programmatically instead - and then realised it was wrong etc..

        public class MyCustomStrategy2 : Strategy
        {
        public MyCustomStrategy2()
        {
        this.State= State.Default;
        this.State= State.Configuration;
        this.State= State.Active;

        //// or something like taht
        }


        so just warning incompetent coders like me can crash NT8 :-)
        MicroTrends
        NinjaTrader Ecosystem Vendor - micro-trends.co.uk

        Comment


          #5
          Originally posted by MicroTrends View Post

          so just warning incompetent coders like me can crash NT8 :-)
          Always has and always will be the case

          Try using the SetState() method instead...
          MatthewNinjaTrader Product Management

          Comment


            #6
            Originally posted by MicroTrends View Post
            ok so i tried to autostart the strategy in the constructor :-)
            i toll the code out again... NT8 crashed out on this one

            2015-05-12 10:54:31:099 ERROR: Error on getting/setting property 'BarsRequiredToTrade' for NinjaScript 'MicroTrends USAR Trader': Exception has been thrown by the target of an invocation.
            2015-05-12 10:54:31:133 *************** unhandled exception trapped ***************
            2015-05-12 10:54:31:133 'BarsRequiredToTrade' cannot be set from this state. Please see the Help Guide article on 'BarsRequiredToTrade' for more information.
            2015-05-12 10:54:31:166 System.InvalidOperationException: 'BarsRequiredToTrade' cannot be set from this state. Please see the Help Guide article on 'BarsRequiredToTrade' for more information.
            at NinjaTrader.NinjaScript.StrategyBase.set_BarsRequi redToTrade(Int32 value)
            at NinjaTrader.NinjaScript.StrategyBase.CopyTo(NinjaS cript ninjaScript)
            at NinjaTrader.NinjaScript.NinjaScript.Clone()
            at NinjaTrader.Gui.NinjaScript.StrategyAnalyzer.Strat egyAnalyzerViewModel.<OnRecompile>b__34()
            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.CompilerServices.TaskAwaiter.ThrowF orNonSuccess(Task task)
            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.OnRecompile(Object sender, EventArgs e)
            at System.EventHandler.Invoke(Object sender, EventArgs e)
            at NinjaTrader.Code.Compiler.Compile(Boolean checkCompileOnly, Boolean debugBuild, IEnumerable`1 filesToIgnore, IEnumerable`1 filesInTmp)
            at NinjaTrader.Gui.NinjaScript.Editor.EditorViewModel .<>c__DisplayClass8c.<OnCompile>b__86(Object s)
            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()
            2015-05-12 10:54:31:167 ERROR: There are no email share services defined. You need to define one and set "Default" to true for email to work.
            That call stack should not crash NT. Fixed with next beta: #8220. Thanks for reporting.

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Irukandji, Today, 04:58 AM
            0 responses
            2 views
            0 likes
            Last Post Irukandji  
            Started by fitspressoburnfat, Today, 04:25 AM
            0 responses
            2 views
            0 likes
            Last Post fitspressoburnfat  
            Started by Skifree, Today, 03:41 AM
            1 response
            4 views
            0 likes
            Last Post Skifree
            by Skifree
             
            Started by usazencort, Today, 01:16 AM
            0 responses
            1 view
            0 likes
            Last Post usazencort  
            Started by kaywai, 09-01-2023, 08:44 PM
            5 responses
            604 views
            0 likes
            Last Post NinjaTrader_Jason  
            Working...
            X