Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Rithmic OnPositionUpdate crash

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

    Rithmic OnPositionUpdate crash

    My strategy works perfectly on Tradovate accounts. One of my customers uses Rithmic and whenever my strategy opens a position, her NT8 crashes completely.

    Here's the error in Trace:

    Rithmic.Adapter.OnPositionUpdate Apex CME NQH5 1 21662 1734618638 840000
    2024-12-19 09:33:11:355 ERROR: Error in realtime market data handling: System.NullReferenceException: Object reference not set to an instance of an object. at NinjaTrader.Gui.AccountData.PnLForegroundConverter .get_Profit() at NinjaTrader.Gui.AccountData.PnLForegroundConverter .Convert(Object value, Type targetType, Object parameter, CultureInfo culture) at System.Windows.Data.BindingExpression.TransferValu e(Object newValue, Boolean isASubPropertyChange) at MS.Internal.Data.PropertyPathWorker.UpdateSourceVa lueState(Int32 k, ICollectionView collectionView, Object newValue, Boolean isASubPropertyChange) at MS.Internal.Data.ClrBindingWorker.OnSourceProperty Changed(Object o, String propName) at System.Windows.WeakEventManager.ListenerList`1.Del iverEvent(Object sender, EventArgs e, Type managerType) at System.ComponentModel.PropertyChangedEventManager. OnPropertyChanged(Object sender, PropertyChangedEventArgs args) at NinjaTrader.Gui.NotifyPropertyChangedBase.OnProper tyChanged(String propertyName) at NinjaTrader.Gui.AccountData.PositionGrid.CheckUpda te(PositionGridEntry item, List`1 propertyNames) at NinjaTrader.Gui.AccountData.PositionGrid.OnRealtim eDataTimerTick(Object sender, EventArgs e) at NinjaTrader.Cbi.Instrument.<>c__DisplayClass153_0. <OnRealtimeDataTimerElapsed>g__Action|1(Subscrib ed Thread[] threads, Int32 i, RealtimeEvents evts)

    I'm unaware of any special documentation just for working with Rithmic accounts in a strategy. Can someone help me please? I need to get this fixed for my customer and send her a new version.

    Thanks!​

    #2
    Hello iantriestrading,

    Please try updating to 8.1.4.0.


    If the error can be reproduced, please provide the open source script causing the error.
    Chelsea B.NinjaTrader Customer Service

    Comment


      #3
      Hi Chelsea, I cannot update to 8.1.4 just to see if it will fix it.
      I use Replikanto and I apparently 8.1.4 has a bug with Orders tab as described below:

      "The issue occurs when a market order is placed on the leader account. NinjaTrader fails to update and display the order on the NinjaTrader Orders Tab, preventing Replikanto from receiving the necessary Order notification and data to do the copy, because the order doesn't exist in the NinjaTrader. We have already sent all the details to the NinjaTrader platform team related to this issue and are awaiting their response. Rest assured, we will update you all as soon as we receive further information.​"


      I see 8.1.4 updates Rithmic API to 13.4.0.0.
      Guess I'm in a catch 22..
      Last edited by iantriestrading; 12-19-2024, 01:36 PM.

      Comment


        #4
        Hello iantriestrading,

        I am not seeing a report on our system with this description.

        Did the vendor receive a tracking ID for this report?
        If so, what is the ID?

        Are you able to reproduce this error when Replikanto is removed from the system?
        Chelsea B.NinjaTrader Customer Service

        Comment


          #5
          Hi Chelsea,

          I have not tried to reproduce the Orders tab "bug" as I have not updated to 8.1.4. If it is really a bug, then I don't want to break my ability to copy trades to all my accounts until the next NT version release.

          Is it a safe bet that the crash error I pasted in my original post is caused by outdated Rithmic API in my 8.1.3.1 NT8 version?
          Or is it likely due to my strategy code?

          I wish I could test with a Rithmic account. I can't use Rithmic paper trading accounts with Ninjatrader. Is it possible for your team to send me any test account I can use for Rithmic connection in NT8 to debug my strategy?

          Comment


            #6
            Hello iantriestrading,

            I'm not aware of a bug but if there is one it should be reproduced and reported so it can be corrected.

            Unfortunately, I do not have a test rithmic account I can provide you. From my understanding one of our developers uses their personal funded account for testing.

            I would be interested to know if the behavior can be reproduced without Replikanto. This might provide insight if something in the addon is causing an issue.
            For instance if the account object or account.Positions collection is locked, this might be causing this error.
            Chelsea B.NinjaTrader Customer Service

            Comment


              #7
              Hi Chelsea, even after updating to 8.1.4.1, my customers are still getting null reference errors related to account PnL, and their NT completely freezes. (when running my strategy)

              Code:
              Error in realtime market data handling: System.NullReferenceException: Object reference not set to an instance of an object.
              at NinjaTrader.Gui.AccountData.PnLForegroundConverter .get_Profit()
              at NinjaTrader.Gui.AccountData.PnLForegroundConverter .Convert(Object value, Type targetType, Object parameter, CultureInfo culture)
              at System.Windows.Data.BindingExpression.TransferValu e(Object newValue, Boolean isASubPropertyChange)
              at MS.Internal.Data.PropertyPathWorker.UpdateSourceVa lueState(Int32 k, ICollectionView collectionView, Object newValue, Boolean isASubPropertyChange)
              at MS.Internal.Data.ClrBindingWorker.OnSourceProperty Changed(Object o, String propName)
              at System.Windows.WeakEventManager.ListenerList`1.Del iverEvent(Object sender, EventArgs e, Type managerType)
              at System.ComponentModel.PropertyChangedEventManager. OnPropertyChanged(Object sender, PropertyChangedEventArgs args)
              at NinjaTrader.Gui.NotifyPropertyChangedBase.OnProper tyChanged(String propertyName)
              at NinjaTrader.Gui.AccountData.PositionGrid.CheckUpda te(PositionGridEntry item, List`1 propertyNames)
              at NinjaTrader.Gui.AccountData.PositionGrid.OnRealtim eDataTimerTick(Object sender, EventArgs e)
              at NinjaTrader.Cbi.Instrument.<>c__DisplayClass153_0. <OnRealtimeDataTimerElapsed>g__Action|1(Subscribed Thread[] threads, Int32 i, RealtimeEvents evts)​
              I'm thinking that maybe my strategy has some race conditions and lacks defensive programming, and because my PC is really fast, I never experience these errors, but my customers who have slightly less performative PCs all experience this. It's 3 people with same freezing issue, vs me with no issues.

              Does my intuition sound right?

              Comment


                #8
                Hello iantriestrading,

                This is a managed approach strategy using native strategy methods like EnterLong() / ExitLongStopMarket() / etc?

                To confirm the script is not adding event handlers to Account events or looping through Account collections?
                Chelsea B.NinjaTrader Customer Service

                Comment


                  #9
                  Hey Chelsea,

                  This is an unmanaged approach strategy. I'm currently thinking that there's some faulty code in my OnBarUpdate causing it to run my CheckPnL method when a position is in the process of opening, or just opened and the account pnl data isn't ready just yet.

                  Claude (in Cursor) says "Looking at your OnBarUpdate, there are several places where account data access could lead to race conditions and potential null reference issues, especially during position updates and PnL checks. The error specifically mentions PnLForegroundConverter, which suggests the issue occurs when NinjaTrader tries to update its GUI with position/account data."

                  So I'm working on this direction currenly.

                  Comment


                    #10
                    Hello iantriestrading,

                    What is the specific line of code causing the error?

                    If you are uncertain, comment out all code and confirm the error stops, then uncomment one line at a time testing for the behavior until the error returns.

                    The last uncommented line is likely the source of the error.
                    Chelsea B.NinjaTrader Customer Service

                    Comment


                      #11
                      Originally posted by NinjaTrader_ChelseaB View Post
                      Hello iantriestrading,

                      What is the specific line of code causing the error?

                      If you are uncertain, comment out all code and confirm the error stops, then uncomment one line at a time testing for the behavior until the error returns.

                      The last uncommented line is likely the source of the error.
                      It's a bit tough with 12,000 lines of code at this point 😆
                      The problem is I cannot replicate the error on my system. Only my customers experience it. So to test, I have to send them a new version and wait for them to test it, and send me log/trace files.
                      I found some areas in my OnBarUpdate, CheckPnL and some other methods which could definitely have caused race conditions, and I'm working improving. Build this bot has been a course in defensive programming, where i have learned I am really lacking!

                      Comment


                        #12
                        Hello iantriestrading,

                        If this is something that isn't occurring on your system or occurs rarely, it would be advised to write logging information to a separate text file using StreamWriter to diagnose the issue.
                        Join the official NinjaScript Developer Community for comprehensive resources, documentation, and community support. Build custom indicators and automated strategies for the NinjaTrader platforms with our extensive guides and APIs.


                        I would recommend printing line numbers above each condition, assignment, and method call to show what parts of the code are evaluating when the crash occurs.

                        If you suspect specific parts of the code, write the values being compared in conditions, used in calculations, or are being submitted to method calls.

                        Below is a link to an example script that writes information to file.
                        Chelsea B.NinjaTrader Customer Service

                        Comment


                          #13
                          Oh wow, thank you! I'll get working on this and update you as soon as I make progress

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by NullPointStrategies, Yesterday, 05:17 AM
                          0 responses
                          54 views
                          0 likes
                          Last Post NullPointStrategies  
                          Started by argusthome, 03-08-2026, 10:06 AM
                          0 responses
                          130 views
                          0 likes
                          Last Post argusthome  
                          Started by NabilKhattabi, 03-06-2026, 11:18 AM
                          0 responses
                          72 views
                          0 likes
                          Last Post NabilKhattabi  
                          Started by Deep42, 03-06-2026, 12:28 AM
                          0 responses
                          44 views
                          0 likes
                          Last Post Deep42
                          by Deep42
                           
                          Started by TheRealMorford, 03-05-2026, 06:15 PM
                          0 responses
                          49 views
                          0 likes
                          Last Post TheRealMorford  
                          Working...
                          X