Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Wrong error message

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

    Wrong error message

    Use the attached indicator. Try loading it onto a chart.

    You will get the message in the picture.

    The message seems to be wrong. The issue has nothing to do with the DisplayInDataBox property: it is due to an attempt to access the Bars object too early. And in any case, we can most assuredly set DisplayInDataBox from right there! The Wizard put it there.

    We should have error messages that at least point to the real problem.

    Trace:
    ====
    2015-05-22 16:54:26:358 ERROR: Indicator 'WrongErrorMessage': Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.
    2015-05-22 16:54:38:828 ERROR: Indicator 'WrongErrorMessage': Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.
    2015-05-22 16:54:38:832 ERROR: Error on getting/setting property 'DisplayInDataBox' for NinjaScript 'WrongErrorMessage': Exception has been thrown by the target of an invocation.
    2015-05-22 16:54:38:836 *************** unhandled exception trapped ***************
    2015-05-22 16:54:38:836 'DisplayInDataBox' cannot be set from this state. Please see the Help Guide article on 'DisplayInDataBox' for more information.
    2015-05-22 16:54:38:876 System.InvalidOperationException: 'DisplayInDataBox' cannot be set from this state. Please see the Help Guide article on 'DisplayInDataBox' for more information.
    at NinjaTrader.NinjaScript.IndicatorBase.set_DisplayI nDataBox(Boolean value)
    at NinjaTrader.NinjaScript.IndicatorBase.CopyTo(Ninja Script ninjaScript)
    at NinjaTrader.Gui.NinjaScript.IndicatorRenderBase.Co pyTo(NinjaScript ninjaScript)
    at NinjaTrader.NinjaScript.NinjaScript.Clone()
    at NinjaTrader.Gui.NinjaScript.IndicatorRenderBase.Cl one()
    at NinjaTrader.Gui.Tools.IndicatorSelector.<.ctor>b__ 8(Object selected)
    at NinjaTrader.Gui.Tools.ObjectDialogViewModel`1.OnAd dItem(Object selected)
    at NinjaTrader.Gui.Tools.ObjectDialogViewModel`1.OnAv ailableDoubleClick()
    at NinjaTrader.Gui.Tools.ObjectDialog.OnAvailableDoub leClick(Object sender, MouseButtonEventArgs 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.Controls.Control.HandleDoubleClick( Object sender, MouseButtonEventArgs 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.ReRaiseEventAs(Dependency Object sender, RoutedEventArgs args, RoutedEvent newEvent)
    at System.Windows.UIElement.OnMouseDownThunk(Object sender, MouseButtonEventArgs 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.InputProviderSite.ReportInput (InputReport inputReport)
    at System.Windows.Interop.HwndMouseInputProvider.Repo rtInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
    at System.Windows.Interop.HwndMouseInputProvider.Filt erMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
    at System.Windows.Interop.HwndSource.InputFilterMessa ge(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
    at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
    at MS.Win32.HwndSubclass.DispatcherCallbackOperation( Object o)
    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)
    Edit: The issue is not how to solve the problem, by concatenating the strings in another place. I have already solved the issue of having a valid indicator that is usable. The issue is that the error message is so misleading, that it was of absolutely no use in solving the problem.
    Attached Files
    Last edited by koganam; 05-22-2015, 08:00 PM.

    #2
    I created a similar error when changing some settings in an indicator. The error only showed when the Data Box was open. Did you have the databox open when you added this indicator?

    EDIT: Could be related to this issue:
    Last edited by NJA_MC; 05-22-2015, 05:29 PM.

    Comment


      #3
      Originally posted by NJA_MC View Post
      I created a similar error when changing some settings in an indicator. The error only showed when the Data Box was open. Did you have the databox open when you added this indicator?

      EDIT: Could be related to this issue:
      http://www.ninjatrader.com/support/f...ad.php?t=74224
      Nope. I did not have the DataBox open. I even restarted NT8 and started over, just to be sure that it was not just a fluke.
      Last edited by koganam; 05-24-2015, 12:29 PM. Reason: Corrected spacing.

      Comment


        #4
        Hm. This is a tad worse in my installation. The file that I posted breaks NT8, so far beyond redemption, at least on my installation.

        Once I got this and shutdown, and restarted NT8, I saw in the log that something was not properly serialized, and all the indicators had disappeared from my charts. I first tried to put back a shipping NT8 indicator, and promptly got a message:
        2015-05-23 01:19:14:110 ERROR: Indicator 'Aroon': Error on calling 'OnBarUpdate' method on bar 288: Object reference not set to an instance of an object.
        That bar seems to be the last bar on the chart. I decided that I did not want to count manually, and it looked about right. Naturally, my BarCount indicator would not have run either, so I could not use that to verify that that is the last bar.

        I marked the errant indicator that I posted to "Exclude From Compilation", then recompiled. I got the same error. So now I tried 3 other native NT8 indicators with the same result.

        Next, I removed ALL my indicators from the NT8 indicators directory, recompiled and tried again with the same result.

        Next. Shutdown NT8. Delete NinjaTrader.Custom.dll and NinjaTrader.Custom.xml. Restart NT8 to get a fresh build. Same result when I tried to add any indicator (now I have only native NT8 indicators in the installation: all my own indicators have been deleted, not just prevented from being compiled).

        Next. Repair installation. Same result.

        Next. Remove and reinstall NT8. Same result.

        So now it looks like once I got that error, my installation is totally fubar.

        Next action is going to be me taking an axe to the NT8 installation, and starting from scratch. That means that I will delete all NT directories, both Program and Data. Then do a new installation of NT8Beta1.

        I am wondering if anyone is willing to take a chance on their installation and see if they can duplicate my results.
        Last edited by koganam; 05-24-2015, 11:34 AM.

        Comment


          #5
          I installed the original code you posted and got the same message box.

          I only see in my log this message when bringing up the indicator list:

          Time Category Message
          5/24/2015 1:37 PM Default Indicator 'WrongErrorMessage': Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.
          Time Category Message
          5/24/2015 1:38 PM Default Error on getting/setting property 'DisplayInDataBox' for NinjaScript 'WrongErrorMessage': Exception has been thrown by the target of an invocation.

          Time Category Message
          5/24/2015 1:38 PM Default Unhandled exception: 'DisplayInDataBox' cannot be set from this state. Please see the Help Guide article on 'DisplayInDataBox' for more information.

          Comment


            #6
            Originally posted by sledge View Post
            I installed the original code you posted and got the same message box.

            I only see in my log this message when bringing up the indicator list:

            Time Category Message
            5/24/2015 1:37 PM Default Indicator 'WrongErrorMessage': Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.
            Time Category Message
            5/24/2015 1:38 PM Default Error on getting/setting property 'DisplayInDataBox' for NinjaScript 'WrongErrorMessage': Exception has been thrown by the target of an invocation.

            Time Category Message
            5/24/2015 1:38 PM Default Unhandled exception: 'DisplayInDataBox' cannot be set from this state. Please see the Help Guide article on 'DisplayInDataBox' for more information.
            What happens when you try to load any other indicator?

            What happens when you restart NinjaTrader, and then try to load indicators?

            Thanks for trying.
            Last edited by koganam; 05-24-2015, 12:17 PM.

            Comment


              #7
              Originally posted by koganam View Post
              What happens when you try to load any other indicator?

              What happens when you restart NinjaTrader?

              Thanks for trying.
              They appear to work without issue. Aroon/Williams/Key reversal up.. just randomly selected and added to chart.

              I did bring up a new ninjascript editor, to exclude that indicator from compilation.

              I can't find it! But it is available in the charts.

              I had another one (copy) that I had played with and removed - it is no longer anywhere. Strange.

              I've restarted several times.

              Comment


                #8
                Originally posted by sledge View Post
                They appear to work without issue. Aroon/Williams/Key reversal up.. just randomly selected and added to chart.

                I did bring up a new ninjascript editor, to exclude that indicator from compilation.

                I can't find it! But it is available in the charts.

                I had another one (copy) that I had played with and removed - it is no longer anywhere. Strange.

                I've restarted several times.
                Hm. So basically, you cannot duplicate my FUBAR. You only get the one failure for the specific indicator?

                Well, time for the axe.

                Thanks.

                Comment


                  #9
                  Connecting to playback is causing other odd things:

                  Time Category Message
                  5/24/2015 2:29 PM Default Error on committing DB changes: System.Data.SqlServerCe.SqlCeException (0x80004005): A duplicate value cannot be inserted into a unique index. [ Table name = Strategies,Constraint name = PK__Strategies__00000000000003AB ] at System.Data.SqlServerCe.SqlCeCommand.ProcessResult s(Int32 hr) at System.Data.SqlServerCe.SqlCeCommand.ExecuteComman dText(IntPtr& pCursor, Boolean& isBaseTableCursor) at System.Data.SqlServerCe.SqlCeCommand.ExecuteComman d(CommandBehavior behavior, String method, ResultSetOptions options) at System.Data.SqlServerCe.SqlCeCommand.ExecuteNonQue ry() at NinjaTrader.NinjaScript.StrategyBase.DbAdd() at NinjaTrader.Cbi.DB.DBThread()

                  Time Category Message
                  5/24/2015 2:29 PM Default Indicator 'WrongErrorMessage': Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.

                  Time Category Message
                  5/24/2015 2:30 PM Default Indicator 'EMA': Error on calling 'OnRender' method on bar -1: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.

                  Time Category Message
                  5/24/2015 2:30 PM Default Indicator 'SMA': Error on calling 'OnRender' method on bar -1: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.

                  Time Category Message
                  5/24/2015 2:30 PM Default Indicator 'ADL': Error on calling 'OnRender' method on bar -1: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.

                  Comment


                    #10
                    Originally posted by sledge View Post
                    Connecting to playback is causing other odd things:

                    Time Category Message
                    5/24/2015 2:29 PM Default Error on committing DB changes: System.Data.SqlServerCe.SqlCeException (0x80004005): A duplicate value cannot be inserted into a unique index. [ Table name = Strategies,Constraint name = PK__Strategies__00000000000003AB ] at System.Data.SqlServerCe.SqlCeCommand.ProcessResult s(Int32 hr) at System.Data.SqlServerCe.SqlCeCommand.ExecuteComman dText(IntPtr& pCursor, Boolean& isBaseTableCursor) at System.Data.SqlServerCe.SqlCeCommand.ExecuteComman d(CommandBehavior behavior, String method, ResultSetOptions options) at System.Data.SqlServerCe.SqlCeCommand.ExecuteNonQue ry() at NinjaTrader.NinjaScript.StrategyBase.DbAdd() at NinjaTrader.Cbi.DB.DBThread()

                    Time Category Message
                    5/24/2015 2:29 PM Default Indicator 'WrongErrorMessage': Error on calling 'OnStateChange' method: Object reference not set to an instance of an object.

                    Time Category Message
                    5/24/2015 2:30 PM Default Indicator 'EMA': Error on calling 'OnRender' method on bar -1: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.

                    Time Category Message
                    5/24/2015 2:30 PM Default Indicator 'SMA': Error on calling 'OnRender' method on bar -1: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.

                    Time Category Message
                    5/24/2015 2:30 PM Default Indicator 'ADL': Error on calling 'OnRender' method on bar -1: You are accessing an index with a value that is invalid since it is out-of-range. I.E. accessing a series [barsAgo] with a value of 5 when there are only 4 bars on the chart.
                    Hm. Looks like I may have written the indiacator that broke NT8.

                    It seems to me that they need to write a new test suite that checks what happens when anything that is verboten in a given state, is accessed in that state in OnStateChanged()..
                    Last edited by koganam; 05-07-2016, 11:54 AM. Reason: Corrected spelling and grammar.

                    Comment


                      #11
                      Originally posted by koganam View Post
                      Hm. Looks like a may have written the indiacator that broke NT8.
                      I think the SMA/EMA/ADL might be when I was playing with drag'n'drop indicators from one chart to another. (I still have those charts up). Oddly - only the SMA was moved from chart A to chart B into the ADL panel (so it's an SMA of the ADL).. the EMA is on a bar series.

                      My imported from NT7 replay data doesn't play back properly (it skips around A LOT (days/months) on Market Replay)... and the historical playback plays back like Market Replay in NT7...

                      I think I need Beta2.

                      Comment


                        #12
                        The misleading error message has been fixed in B2.

                        If you're still having issues, the primary cause was the use of the private ChartID string which is attempting to get the instrument/bars info at the time of SetDefaults, which is not avaiable then. If you move this to State.Configure, it should work as expected (and without breaking all other indicators, since SetDefault is a global call like we had with NT7's Initialize()

                        Code:
                        else if (State == State.Configure)
                        {
                        	NewBarFormed					= "New Bar" + " - " + ChartId;
                        }
                        MatthewNinjaTrader Product Management

                        Comment


                          #13
                          Originally posted by NinjaTrader_Matthew View Post
                          The misleading error message has been fixed in B2.

                          If you're still having issues, the primary cause was the use of the private ChartID string which is attempting to get the instrument/bars info at the time of SetDefaults, which is not avaiable then. If you move this to State.Configure, it should work as expected (and without breaking all other indicators, since SetDefault is a global call like we had with NT7's Initialize()

                          Code:
                          else if (State == State.Configure)
                          {
                          	NewBarFormed					= "New Bar" + " - " + ChartId;
                          }
                          Thanks for the confirmation, Matthew, but as my original post said:
                          The message seems to be wrong. The issue has nothing to do with the DisplayInDataBox property: it is due to an attempt to access the Bars object too early.
                          so, I had already solved the issue before I posted the error, as, again from my original post:
                          Edit: The issue is not how to solve the problem, by concatenating the strings in another place. I have already solved the issue of having a valid indicator that is usable. The issue is that the error message is so misleading, that it was of absolutely no use in solving the problem.

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by jpapa, Today, 07:22 AM
                          1 response
                          5 views
                          0 likes
                          Last Post NinjaTrader_Gaby  
                          Started by kevinenergy, 02-17-2023, 12:42 PM
                          116 responses
                          2,758 views
                          1 like
                          Last Post kevinenergy  
                          Started by franatas, 12-04-2023, 03:43 AM
                          7 responses
                          106 views
                          0 likes
                          Last Post NinjaTrader_ChelseaB  
                          Started by Jltarrau, Today, 05:57 AM
                          3 responses
                          9 views
                          0 likes
                          Last Post Jltarrau  
                          Started by f.saeidi, Today, 05:56 AM
                          2 responses
                          9 views
                          0 likes
                          Last Post NinjaTrader_Erick  
                          Working...
                          X