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

SuperDomCustomColumnRender error

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

    SuperDomCustomColumnRender error

    I created a new super dom column and when I change values in the indicator or shutdown the platform I'm getting unhandled exceptions similar to the ones listed below. They are very intermittent. I'm not sure why this is occurring since I have try / catch statements wrapping all my logic in OnRender. Do I need to add try / catch somewhere else?

    log file:

    Code:
    2024-03-22 08:46:44:844|0|4|Unhandled exception: Object reference not set to an instance of an object.
    2024-03-22 08:47:11:477|0|4|Unhandled exception: Specified argument was out of the range of valid values. Parameter name: Index is out of collection's boundary.
    2024-03-22 08:57:06:568|0|4|Unhandled exception: Object reference not set to an instance of an object.​
    trace file:

    Code:
    2024-03-22 08:46:44:844 System.NullReferenceException: Object reference not set to an instance of an object.
    at NinjaTrader.Gui.SuperDom.SuperDomCustomColumnRende r.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
    at System.Collections.ObjectModel.ObservableCollectio n`1.OnCollectionChanged(NotifyCollectionChangedEve ntArgs e)
    at NinjaTrader.Gui.SuperDom.ObservableNotifiableColle ction`1.OnCollectionChanged(NotifyCollectionChange dEventArgs e)
    at System.Collections.ObjectModel.ObservableCollectio n`1.RemoveItem(Int32 index)
    at System.Collections.ObjectModel.Collection`1.Remove (T item)
    at NinjaTrader.Gui.SuperDom.SuperDomControl.HandleCol umn(SuperDomColumn column, Operation operation, Int32 addIndex)
    at NinjaTrader.Gui.SuperDom.SuperDomControl.ResetCust omColumns()
    at NinjaTrader.Gui.SuperDom.SuperDomControl.OnReloadN injaScript()
    at NinjaTrader.Gui.SuperDom.SuperDomControl.OnReloadN injaScriptHotKey(Object sender, KeyEventArgs e)
    at NinjaTrader.Gui.HotKeys.HotKeysManager.TrySuperDom HotKey(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)
    2024-03-22 08:47:11:475 *************** unhandled exception trapped ***************
    2024-03-22 08:47:11:475 Specified argument was out of the range of valid values.
    Parameter name: Index is out of collection's boundary.
    2024-03-22 08:47:11:477 System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values.
    Parameter name: Index is out of collection's boundary.
    at System.Windows.Controls.ColumnDefinitionCollection .RemoveAt(Int32 index)
    at NinjaTrader.Gui.SuperDom.SuperDomCustomColumnRende r.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
    at System.Collections.ObjectModel.ObservableCollectio n`1.OnCollectionChanged(NotifyCollectionChangedEve ntArgs e)
    at NinjaTrader.Gui.SuperDom.ObservableNotifiableColle ction`1.OnCollectionChanged(NotifyCollectionChange dEventArgs e)
    at System.Collections.ObjectModel.ObservableCollectio n`1.RemoveItem(Int32 index)
    at System.Collections.ObjectModel.Collection`1.Remove (T item)
    at NinjaTrader.Gui.SuperDom.SuperDomControl.HandleCol umn(SuperDomColumn column, Operation operation, Int32 addIndex)
    at NinjaTrader.Gui.SuperDom.SuperDomControl.ResetCust omColumns()
    at NinjaTrader.Gui.SuperDom.SuperDomControl.OnReloadN injaScript()
    at NinjaTrader.Gui.SuperDom.SuperDomControl.OnReloadN injaScriptHotKey(Object sender, KeyEventArgs e)
    at NinjaTrader.Gui.HotKeys.HotKeysManager.TrySuperDom HotKey(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)
    2024-03-22 08:57:06:567 *************** unhandled exception trapped ***************
    2024-03-22 08:57:06:567 Object reference not set to an instance of an object.
    2024-03-22 08:57:06:568 System.NullReferenceException: Object reference not set to an instance of an object.
    at NinjaTrader.Gui.SuperDom.SuperDomCustomColumnRende r.OnCollectionChanged(Object sender, NotifyCollectionChangedEventArgs e)
    at System.Collections.ObjectModel.ObservableCollectio n`1.OnCollectionChanged(NotifyCollectionChangedEve ntArgs e)
    at NinjaTrader.Gui.SuperDom.ObservableNotifiableColle ction`1.OnCollectionChanged(NotifyCollectionChange dEventArgs e)
    at System.Collections.ObjectModel.ObservableCollectio n`1.RemoveItem(Int32 index)
    at System.Collections.ObjectModel.Collection`1.Remove (T item)
    at NinjaTrader.Gui.SuperDom.SuperDomControl.HandleCol umn(SuperDomColumn column, Operation operation, Int32 addIndex)
    at NinjaTrader.Gui.SuperDom.SuperDomControl.<>c__Disp layClass162_0.<OnColumns>g__ApplyChanges|0()
    at NinjaTrader.Gui.SuperDom.SuperDomControl.OnColumns ()
    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.MenuItem.InvokeClickAfterR ender(Object arg)
    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)

    #2
    Hello habibalex,

    It means one of the variables you are using has a null value and one of the collections being accessed does not have the index.
    You'll need to identify the variable and check for null, and identify the collection and ensure elements are being fetched with a valid index.

    If you are unsure what is causing the issue, comment out all logic and ensure the behavior stops.
    Then uncomment code one line at a time until the behavior returns.

    Alternatively, debug the script with prints to identify the specific line causing the error.



    Below is a link to a User App Share script that does GDI+ rendering from a SuperDOMColumn you may find helpful.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea, Is there a specific section of code that one of the overridden methods ie: (OnMarketDepthUpdate, OnMarketData, OnStateChange, OnRender) is called from when NinjaTrader.Gui.SuperDom.SuperDomControl.HandleCol umn(SuperDomColumn column, Operation operation, Int32 addIndex)
      at NinjaTrader.Gui.SuperDom.SuperDomControl.ResetCust omColumns()​ executes?

      Comment


        #4
        Hello habibalex,

        Unfortunately, I do not have knowledge of the inner workings of NinjaTrader.
        I've asked our development. If they provide any further information I will forward that here.

        If this is occurring with clicking OK after adding this as a column then OnStateChange() would be a good place to look as this updates as the class is being constructed.
        OnRender() also will start running after this, so this would also be a good place to look.
        Chelsea B.NinjaTrader Customer Service

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by futtrader, 04-21-2024, 01:50 AM
        4 responses
        41 views
        0 likes
        Last Post futtrader  
        Started by Option Whisperer, Today, 09:55 AM
        1 response
        12 views
        0 likes
        Last Post bltdavid  
        Started by port119, Today, 02:43 PM
        0 responses
        8 views
        0 likes
        Last Post port119
        by port119
         
        Started by Philippe56140, Today, 02:35 PM
        0 responses
        7 views
        0 likes
        Last Post Philippe56140  
        Started by 00nevest, Today, 02:27 PM
        0 responses
        7 views
        0 likes
        Last Post 00nevest  
        Working...
        X