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

Empty Multi-Instrument Indicator hangs the chart

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

    Empty Multi-Instrument Indicator hangs the chart

    I've encountered a deadlock bug caused by adding new instruments to an indicator. The deadlock happens after the indicator finishes loading on the inserted chart, then the chart just hangs indefinitely.

    The indicator is just an empty indicator, which adds 28 forex instruments of the same timeframe as the chart. They're added on the State.Configure state, as the documentation suggests.

    I've attached a sample indicator to the post. The steps to reproduce it are:
    - Open the chart of one of the instruments listed on the indicator. e.g GBPAUD
    - Insert the indicator on the chart.
    - Wait for it to finish loading.
    - The chart will hang indefinitely.
    When closing NT8 it also pops up an error and warns about a deadlock-prone programming pattern.
    Click image for larger version  Name:	image_2020-11-05_13-10-12.png Views:	0 Size:	5.9 KB ID:	1126338


    ​​​
    Is this just a NT8 bug, or did I make a mistake? Are there any possible workarounds to prevent this deadlock from happening?
    Last edited by Matheusfx; 11-05-2020, 10:19 AM.

    #2
    Hello Matheusfx,

    Thank you for your post.

    In testing this, I'm definitely seeing behavior I wouldn't expect. I've found that it works fine for me without errors if I comment the last 4 additional series out, but if I instead comment out the first two only, it also works. If I only comment out the first series, it never stops calculating but doesn't freeze the chart. I'm going to send this over to our QA team to take a look at and see what they think. I'll let you know their findings when I receive them.

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

    Comment


      #3
      This behavior is indeed really weird. Do you have any news on this? I really need to proceed development on this indicator, and this is seriously preventing me from continuing.

      Comment


        #4
        Hello Matheusfx,

        Thank you for your reply.

        I have yet to receive word from our development team on this. I will let you know when they respond.

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

        Comment


          #5
          Hello Matheusfx,

          Thank you for your patience.

          I've heard back from our QA team who have let me know that we're going to be releasing a new version soon that should address this. I would suggest waiting a short while until this new update comes out, then testing again and letting us know if you see the same behavior with the update.

          When it's released, it will be noted on the forums here: https://ninjatrader.com/support/foru...nouncements-aa

          Please let us know if we may be of further assistance to you.
          Kate W.NinjaTrader Customer Service

          Comment


            #6
            I updated to the new version, and the issue seems to be fixed! Thank you so much

            Comment


              #7
              I've encountered another deadlock, passing around the Series' which contain values of the bars of the other instruments inside OnBarUpdate also hangs NinjaTrader.

              There's an example of the bug attached to this post, it simply creates an SMA for each one of the added instruments. It doesn't even access its values and already hangs the chart after a NinjaScript reload. I've tested it on a GBPAUD 5 Minute Chart.

              For some reason, adding these kinds of indicators to the Market Analyzer does not hand the Market Analyzer, only adding it to charts does.

              Are there any workarounds to prevent this until a new version comes out? I need this ASAP.
              Attached Files
              Last edited by Matheusfx; 01-25-2021, 03:46 PM.

              Comment


                #8
                Hello Matheusfx,

                Thank you for your reply.

                I will do some testing and let you know my findings. As it's rather late in my day it will likely be tomorrow before I can complete testing.

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

                Comment


                  #9
                  Okay, thanks!

                  I've done a bit more testing, and the actual deadlock seems to be happening only with a custom Minute bars I had inserted, which changes the bars from being end-time based to start-time based.

                  Even though I wasn't able to reproduce the deadlock on the native Minute bars, I get this error on the Control Center Logs when running it:
                  Failed to call 'Add' method: System.Threading.LockRecursionException: Write lock may not be acquired with read lock held. This pattern is prone to deadlocks. Please ensure that read locks are released before taking a write lock. If an upgrade is necessary, use an upgrade lock in place of the read lock. at System.Threading.ReaderWriterLockSlim.TryEnterWrit eLockCore(TimeoutTracker timeout) at System.Threading.ReaderWriterLockSlim.TryEnterWrit eLock(TimeoutTracker timeout) at NinjaTrader.Data.BarsSeries.Add(Bars bars, Double open, Double high, Double low, Double close, DateTime time, Int64 volume, Double tickSize, Boolean isBar, Double bid, Double ask)

                  Comment


                    #10
                    Hello Matheusfx,

                    Thank you for your patience.

                    I'm not surprised if that's occurring with a custom Minute bars.

                    I'm not able to reproduce the second error on my end. I've been running this for some time and haven't seen it at all. Did the error immediately show up after applying the indicator, or did it take some time to hit? On which instrument were you testing at the time?

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

                    Comment


                      #11
                      I was running it on GBPAUD, it normally happens a short time after messing around with the chart, I tested randomly clicking around, checking data box values, zooming in and out... Using the Reload Ninjascript button usually accelerates the process.

                      I've done some tests with the normal Minute bars, and I can still reproduce this on my main indicator... I'll create another test example that shows this happening on them. Also, after further investigation, I'm pretty sure this deadlock is also happening on Market Analyzer, and it makes it randomly get stuck loading or calculating forever, until a full NinjaTrader restart. I'll also try to replicate it and attach it here on my next post.

                      Do you have any ideas on why the custom bars would impact this? They literally only change the time of the original NT8 bars.

                      Comment


                        #12
                        Hello Matheusfx,

                        Thank you for your reply.

                        I was able to get this to freeze the chart when added, but haven't replicated the error itself thus far. I'll be sending this to our development team to see if it would be expected.

                        As far as the custom bars go, NinjaTrader isn't designed to handle bars with opening time stamps, so I would expect odd behavior when trying to run an indicator using a bar type that uses opening time stamps rather than the expected closing time.

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

                        Comment


                          #13
                          Hello Matheusfx,

                          Thank you for your patience.

                          We've done some more looking into this and the issue that actually seems to be causing the freezing would actually be expected. Basically, it's not having the added data series that's freezing it up, it's that every time one of those series' bars close, you're looping through all 28 series and creating a new SMA instance for each. In practice that basically overloads the whole thing and the chart freezes.

                          In practice, we would recommend setting up instances of the SMA to variables in State == State.DataLoaded, one for each added series. That way each time you're referencing the same instance and reducing the amount of load on your PC resources.

                          Please let us know if we may be of further assistance to you.
                          Kate W.NinjaTrader Customer Service

                          Comment

                          Latest Posts

                          Collapse

                          Topics Statistics Last Post
                          Started by Gerik, Today, 09:40 AM
                          2 responses
                          6 views
                          0 likes
                          Last Post Gerik
                          by Gerik
                           
                          Started by RookieTrader, Today, 09:37 AM
                          2 responses
                          10 views
                          0 likes
                          Last Post RookieTrader  
                          Started by alifarahani, Today, 09:40 AM
                          1 response
                          7 views
                          0 likes
                          Last Post NinjaTrader_Jesse  
                          Started by KennyK, 05-29-2017, 02:02 AM
                          3 responses
                          1,285 views
                          0 likes
                          Last Post NinjaTrader_Clayton  
                          Started by AttiM, 02-14-2024, 05:20 PM
                          11 responses
                          186 views
                          0 likes
                          Last Post NinjaTrader_ChelseaB  
                          Working...
                          X