Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Strategy recompilation error

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

    Strategy recompilation error

    Hi!

    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
    Code:
    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]'.
    But before I do anything

    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
    Code:
    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)
    Code
    ListCollectionStrategy.cs

    With best regards,
    Attached Files
    Last edited by fut_practic; 12-08-2021, 02:04 PM.

    #2
    Hello fut_practic,

    Thank you for your post.

    Are you trying to implement a collection editor for the parameters as SampleIndicatorTypeConverter demonstrates?



    We would really need to see a reduced version of the script with any code unnecessary to reproduce the errors removed (any drawing tools, order placing logic, etc) to see what the issue may be. If you can provide a reduced version I'm happy to take a look.

    Thanks in advance; I look forward to assisting you further.
    Kate W.NinjaTrader Customer Service

    Comment


      #3
      Originally posted by NinjaTrader_Kate View Post
      Hello fut_practic,

      Thank you for your post.

      Are you trying to implement a collection editor for the parameters as SampleIndicatorTypeConverter demonstrates?



      We would really need to see a reduced version of the script with any code unnecessary to reproduce the errors removed (any drawing tools, order placing logic, etc) to see what the issue may be. If you can provide a reduced version I'm happy to take a look.

      Thanks in advance; I look forward to assisting you further.
      Added code

      Comment


        #4
        Hello fut_practic,

        Thank you for your reply.

        No actual NinjaScript was provided, we would need a working reduced example strategy that reproduces the error, not just the error message and stack trace in order to understand what may be occurring.

        You also did not mention if you are trying to implement a collection editor for the parameters, can you confirm whether or not this is the case?

        Thanks in advance; I look forward to assisting you further.
        Kate W.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Kate View Post
          Hello fut_practic,

          Thank you for your reply.

          No actual NinjaScript was provided, we would need a working reduced example strategy that reproduces the error, not just the error message and stack trace in order to understand what may be occurring.

          You also did not mention if you are trying to implement a collection editor for the parameters, can you confirm whether or not this is the case?

          Thanks in advance; I look forward to assisting you further.
          Please check again, I've reupload

          Comment


            #6
            Hello fut_practic,

            Thank you for your reply.

            The code provided is not compilable and appears to be missing references. We would need a working example. Please see the below screenshot:

            Click image for larger version

Name:	2021-12-08_10-45-45.png
Views:	183
Size:	68.4 KB
ID:	1180977

            Please try exporting from Tools > Export NinjaScript Addon. Do not check the box to export as a compiled assembly or I will not be able to review the logic. Attach the resulting .Zip file to your reply.

            Thanks in advance, I look forward to assisting you further.
            Kate W.NinjaTrader Customer Service

            Comment


              #7
              Originally posted by NinjaTrader_Kate View Post
              Hello fut_practic,

              Thank you for your reply.

              The code provided is not compilable and appears to be missing references. We would need a working example. Please see the below screenshot:

              Click image for larger version

Name:	2021-12-08_10-45-45.png
Views:	183
Size:	68.4 KB
ID:	1180977

              Please try exporting from Tools > Export NinjaScript Addon. Do not check the box to export as a compiled assembly or I will not be able to review the logic. Attach the resulting .Zip file to your reply.

              Thanks in advance, I look forward to assisting you further.
              Pls check again

              Comment


                #8
                Hello fut_practic,

                Thank you for your reply.

                I see that the non-exported code has been removed from the original post and I'm not seeing an uploaded .Zip file in its place. I am still unable to compile the originally provided version.

                Thanks in advance; I look forward to assisting you further.
                Kate W.NinjaTrader Customer Service

                Comment


                  #9
                  Originally posted by NinjaTrader_Kate View Post
                  Hello fut_practic,

                  Thank you for your reply.

                  I see that the non-exported code has been removed from the original post and I'm not seeing an uploaded .Zip file in its place. I am still unable to compile the originally provided version.

                  Thanks in advance; I look forward to assisting you further.
                  I'm sorry, fixed.
                  But that version with wrong converter run ok
                  It's simple strategy that does nothing
                  Last edited by fut_practic; 12-08-2021, 01:11 PM.

                  Comment


                    #10
                    Originally posted by NinjaTrader_Kate View Post
                    Hello fut_practic,

                    Thank you for your reply.

                    I see that the non-exported code has been removed from the original post and I'm not seeing an uploaded .Zip file in its place. I am still unable to compile the originally provided version.

                    Thanks in advance; I look forward to assisting you further.
                    Please, check again
                    I reuploaded

                    Comment


                      #11
                      Originally posted by NinjaTrader_Kate View Post
                      Hello fut_practic,

                      Thank you for your reply.

                      I see that the non-exported code has been removed from the original post and I'm not seeing an uploaded .Zip file in its place. I am still unable to compile the originally provided version.

                      Thanks in advance; I look forward to assisting you further.
                      Please provide me valid email and code to send my request
                      This forum renames files after 30mins that it was uploaded, links are becoming unavailable

                      Current problem is imporant and urgent

                      With best regards

                      Comment


                        #12
                        Hello fut_practic,

                        Thank you for your reply.

                        We have been looking at your code and I would point out there are a lot of unsupported things going on such as overriding the constructor, and the script is not isolated to the List input.

                        Have you been able to set this up following SampleIndicatorTypeConverter? This indicator demonstrates using the CollectionEdtior and CopyTo.

                        We are working on an example that implements this in a Strategy but have not yet completed the example. We should have something for you tomorrow.

                        Thanks in advance for your patience.
                        Kate W.NinjaTrader Customer Service

                        Comment


                          #13
                          Hello fut_practic,

                          Thank you for your patience.

                          In attempting to create an example we ran into the same issue and it appears that implementing the same Collection Editor in a strategy and in an indicator will have the strategy fail to reload after recompiling, while the indicator can reload after recompiling. The strategy complains about BarsRequiredToTrade as you're seeing.

                          We've reached out to our QA team to confirm and potentially send to our development team to look at. We're tracking the issue under the number QA-5693. As soon as we have feedback from them we'll let you know, however, at the current time it appears you'll hit that error when recompiling and reloading the strategy.

                          Thanks in advance; I look forward to assisting you further.
                          Kate W.NinjaTrader Customer Service

                          Comment


                            #14
                            Originally posted by NinjaTrader_Kate View Post
                            Hello fut_practic,

                            Thank you for your patience.

                            In attempting to create an example we ran into the same issue and it appears that implementing the same Collection Editor in a strategy and in an indicator will have the strategy fail to reload after recompiling, while the indicator can reload after recompiling. The strategy complains about BarsRequiredToTrade as you're seeing.

                            We've reached out to our QA team to confirm and potentially send to our development team to look at. We're tracking the issue under the number QA-5693. As soon as we have feedback from them we'll let you know, however, at the current time it appears you'll hit that error when recompiling and reloading the strategy.

                            Thanks in advance; I look forward to assisting you further.
                            Please, do the best

                            Because during NT startup I always get error "Unhandled exception: Object reference not set to an instance of an object" due to this bug because CopyTo copies, but then null reference is set to property inside SetDefaults

                            With best regards

                            Click image for larger version

Name:	strategy list error.png
Views:	194
Size:	24.5 KB
ID:	1181843

                            Comment

                            Latest Posts

                            Collapse

                            Topics Statistics Last Post
                            Started by Segwin, 05-07-2018, 02:15 PM
                            14 responses
                            1,789 views
                            0 likes
                            Last Post aligator  
                            Started by Jimmyk, 01-26-2018, 05:19 AM
                            6 responses
                            837 views
                            0 likes
                            Last Post emuns
                            by emuns
                             
                            Started by jxs_xrj, 01-12-2020, 09:49 AM
                            6 responses
                            3,293 views
                            1 like
                            Last Post jgualdronc  
                            Started by Touch-Ups, Today, 10:36 AM
                            0 responses
                            13 views
                            0 likes
                            Last Post Touch-Ups  
                            Started by geddyisodin, 04-25-2024, 05:20 AM
                            11 responses
                            63 views
                            0 likes
                            Last Post halgo_boulder  
                            Working...
                            X