Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ValueChart indicator stopped working with recent update.

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

    ValueChart indicator stopped working with recent update.

    ​​Hi guys, I updated NT from 8.0.22.0 to 8.0.32.1 and now the attached indicator is not visible. It is calculating as seen by the price label on the right edge of the chart is moving. My guess is NT changed something in the OnRender() which is causing the indicator to no longer be visible. This indicator uses OnRender, not Plots to display it data.
    There are no errors in the Log tab. Can you look at the code and explain what changes need to be made to get the indicator working again in 8.0.23.1.
    Thx
    Click image for larger version

Name:	ValueChart not visible.png
Views:	473
Size:	32.3 KB
ID:	1132221

    Attached Files

    #2
    Hello zacharydw00,
    You have commented line 210 (base.OnRender(chartControl, chartScale);), just uncomment it & it'll work fine.
    Hope it helps!

    Comment


      #3
      Hello zacharydw00,

      Thank you for the post.

      Taking a quick look at the code I don't see anything specifically out of place. When you debugged this what did you find was happening differently?

      Other items in the platform also use OnRender but have been unaffected so this likely relates to part of the logic you have.

      If nothing is being drawn at all and there are no errors it may be that one of the conditions you have at the beginning of OnRender is preventing the logic from drawing. This could also relate to the brushes being created. I would suggest to step through with a print first and make sure your OnRender logic is all being called. If so you could also try replacing the brushes you are creating with just a default brush to see if this relates to how the brush was made.


      I look forward to being of further assistance.

      Comment


        #4
        OK, I just noticed it works for a while & vanishes away with scroll, also found some errors in the log, attaching the snapshot while working.
        Found below errors in log:
        2020-12-14 21:33:00:333|3|4|Indicator 'ValueChartSim22': Error on calling 'OnRender' method on bar 5193: Object reference not set to an instance of an object.
        2020-12-14 21:33:02:420|3|4|Indicator 'ValueChartSim22': Error on calling 'OnRender' method on bar 5193: Object reference not set to an instance of an object.
        2020-12-14 21:33:02:857|3|4|Indicator 'ValueChartSim22': Error on calling 'OnRender' method on bar 5193: Object reference not set to an instance of an object.
        2020-12-14 21:33:03:093|3|4|Indicator 'ValueChartSim22': Error on calling 'OnRender' method on bar 5193: Object reference not set to an instance of an object.
        2020-12-14 21:33:03:278|3|4|Indicator 'ValueChartSim22': Error on calling 'OnRender' method on bar 5193: Object reference not set to an instance of an object.
        2020-12-14 21:33:03:454|3|4|Indicator 'ValueChartSim22': Error on calling 'OnRender' method on bar 5193: Object reference not set to an instance of an object.
        2020-12-14 21:33:03:749|3|4|Indicator 'ValueChartSim22': Error on calling 'OnRender' method on bar 5193: Object reference not set to an instance of an object.
        2020-12-14 21:33:04:122|3|4|Indicator 'ValueChartSim22': Error on calling 'OnRender' method on bar 5193: Object reference not set to an instance of an object.
        2020-12-14 21:33:04:349|3|4|Indicator 'ValueChartSim22': Error on calling 'OnRender' method on bar 5193: Object reference not set to an instance of an object.
        2020-12-14 21:33:04:941|3|4|Indicator 'ValueChartSim22': Error on calling 'OnRender' method on bar 5193: Object reference not set to an instance of an object.
        2020-12-14 21:33:05:126|3|4|Indicator 'ValueChartSim22': Error on calling 'OnRender' method on bar 5193: Object reference not set to an instance of an object.
        2020-12-14 21:33:05:341|3|4|Indicator 'ValueChartSim22': Error on calling 'OnRender' method on bar 5193: Object reference not set to an instance of an object.
        2020-12-14 21:33:05:569|3|4|Indicator 'ValueChartSim22': Error on calling 'OnRender' method on bar 5193: Object reference not set to an instance of an object.
        2020-12-14 21:33:06:222|3|4|Indicator 'ValueChartSim22': Error on calling 'OnRender' method on bar 5193: Object reference not set to an instance of an object.
        2020-12-14 21:33:06:445|3|4|Indicator 'ValueChartSim22': Error on calling 'OnRender' method on bar 5193: Object reference not set to an instance of an object.
        2020-12-14 21:33:06:646|3|4|Indicator 'ValueChartSim22': Error on calling 'OnRender' method on bar 5193: Object reference not set to an instance of an object.
        2020-12-14 21:33:06:821|3|4|Indicator 'ValueChartSim22': Error on calling 'OnRender' method on bar 5193: Object reference not set to an instance of an object.
        2020-12-14 21:33:06:994|3|4|Indicator 'ValueChartSim22': Error on calling 'OnRender' method on bar 5193: Object reference not set to an instance of an object.
        2020-12-14 21:33:07:149|3|4|Indicator 'ValueChartSim22': Error on calling 'OnRender' method on bar 5193: Object reference not set to an instance of an object.
        2020-12-14 21:33:08:605|3|4|Indicator 'ValueChartSim22': Error on calling 'OnRender' method on bar 5193: Object reference not set to an instance of an object.
        2020-12-14 21:33:08:789|3|4|Indicator 'ValueChartSim22': Error on calling 'OnRender' method on bar 5193: Object reference not set to an instance of an object.
        2020-12-14 21:33:08:978|3|4|Indicator 'ValueChartSim22': Error on calling 'OnRender' method on bar 5193: Object reference not set to an instance of an object.
        2020-12-14 21:33:09:149|3|4|Indicator 'ValueChartSim22': Error on calling 'OnRender' method on bar 5193: Object reference not set to an instance of an object.

        Comment


          #5
          Quick fix:
          Commenting lines 364 to 374 works fine, here all brushes & region lines are disposed.
          Update:
          Line 210 can be left commented.
          Check at your end for any further issues & fix accordingly.
          Hope it helps!

          Comment


            #6
            Originally posted by s.kinra View Post
            Quick fix:
            Commenting lines 364 to 374 works fine, here all brushes & region lines are disposed.
            Thanks s.kinra ra. That fixed it.
            fyi, I'm not Sim22. Its not my code.
            Last edited by zacharydw00; 12-15-2020, 02:14 PM. Reason: Removed documentation comment. issue is disposing of StrokeStyle objects.

            Comment


              #7
              Hello zacharydw00,

              Based on the errors that s.kinra provided it would seem that some of the brushes may be null so the dispose causes an error. The developer would need to review that to make sure the brushes are being created correctly and not null, otherwise add handling for those cases where they are null. Brushes do need to be disposed however you cannot dispose a null object.

              Rather than commenting out the line which prevents any brushes that do get created from being disposed you could do something like the following:

              Code:
              if(upBrush != null) upBrush.Dispose();
              if (dnBrush != null) dnBrush.Dispose();
              if (olBrush != null) olBrush.Dispose();
              if (muBrush != null) muBrush.Dispose();
              if (mlBrush != null) mlBrush.Dispose();
              if (hiBrush != null) hiBrush.Dispose();
              if (loBrush != null) loBrush.Dispose();
              if (hiSS != null) hiSS.Dispose();
              if (loSS != null) loSS.Dispose();
              if (muSS != null) muSS.Dispose();
              if (mlSS != null) mlSS.Dispose();

              I look forward to being of further assistance.

              Comment


                #8
                Hello,
                I just had another look on the code today morning & noticed brushes seem to be fine. Yesterday commenting out all dispose() things was a prima facie work around.
                What I found is disposing the brushes is not causing any issues so another look at code gave me a chance to find dispose from line 371 to 374 are actually strokestyles & not brushes, so I just commented those & rest remains as it is. This makes the indicator work normally. I am aware of disposing of DX brushes to save memory but I can't figure out disposing of strokestyles, so you can also have a look at your end. Hopefully the owner of this code would be in a better position to fix it.
                I also tried to have the !null conditions for these as suggested by Jesse but it wasn't working. So, I am pretty sure line 371 to 374 is the only culprit.
                Last edited by s.kinra; 12-14-2020, 09:32 PM. Reason: update for null condition

                Comment


                  #9
                  Originally posted by NinjaTrader_Jesse View Post
                  Based on the errors that s.kinra provided it would seem that some of the brushes may be null so the dispose causes an error.
                  Using a null check didn't help... if (hiSS != null) hiSS.Dispose();


                  Based on s.kinra's comments I tested his suggestion and confirmed that disposing of the StrokeStyle objects was causing the issue.
                  Code:
                  SharpDX.Direct2D1.StrokeStyle hiSS = Lines[0].StrokeStyle;
                  SharpDX.Direct2D1.StrokeStyle muSS = Lines[1].StrokeStyle;
                  SharpDX.Direct2D1.StrokeStyle mlSS = Lines[2].StrokeStyle;
                  SharpDX.Direct2D1.StrokeStyle loSS = Lines[3].StrokeStyle;
                  ...
                  ...
                  if (hiSS != null) hiSS.Dispose();
                  if (loSS != null) loSS.Dispose();
                  if (muSS != null) muSS.Dispose();
                  if (mlSS != null) mlSS.Dispose();
                  If the catch() statement is replaced with...
                  Code:
                   catch(Exception ex)
                  { Print("ValueChart: OnRender - "+ex.ToString() ); }
                  this error will print,
                  System.NullReferenceException: Object reference not set to an instance of an object.
                  at SharpDX.Direct2D1.Resource.GetFactory(Factory& factory)
                  at NinjaTrader.Gui.Stroke.get_StrokeStyle()
                  at NinjaTrader.NinjaScript.Indicators.Sim22.Sim22_Val ueChartV1.OnRender(ChartControl chartControl, ChartScale chartScale)


                  To summarize, the Brushes are being disposed of at the end of OnRender(), but the StrokeStyle objects must NOT be disposed of. As of NT 8.0.23.1, and maybe a few updates previous, disposing of StrokeStyle objects may cause issues in OnRender().
                  Last edited by zacharydw00; 12-15-2020, 02:16 PM.

                  Comment


                    #10
                    My modified version.
                    Attached Files

                    Comment

                    Latest Posts

                    Collapse

                    Topics Statistics Last Post
                    Started by Mindset, 04-21-2026, 06:46 AM
                    0 responses
                    67 views
                    0 likes
                    Last Post Mindset
                    by Mindset
                     
                    Started by M4ndoo, 04-20-2026, 05:21 PM
                    0 responses
                    95 views
                    0 likes
                    Last Post M4ndoo
                    by M4ndoo
                     
                    Started by M4ndoo, 04-19-2026, 05:54 PM
                    0 responses
                    53 views
                    0 likes
                    Last Post M4ndoo
                    by M4ndoo
                     
                    Started by cmoran13, 04-16-2026, 01:02 PM
                    0 responses
                    108 views
                    0 likes
                    Last Post cmoran13  
                    Started by PaulMohn, 04-10-2026, 11:11 AM
                    0 responses
                    63 views
                    0 likes
                    Last Post PaulMohn  
                    Working...
                    X