Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

ERROR: Data.ColorSeries.Set

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

    ERROR: Data.ColorSeries.Set

    This has been showing up in trace files:
    2016-07-19 07:48:20:525 ERROR: Data.ColorSeries.Set: Color series exceeds the maximum number (65535) of unique brushes. Please adjust code to use fewer brushes.
    I've enclosed much of my code within try/catch, but no exceptions are caught that match the trace file, so I can't be sure where the problem might be.

    Today, I encountered a different error caught in my custom OnRender(): External component has thrown an exception. This has the unfortunate effect of freezing all charts and the SuperDOM. A Basic Entry window and T&S window continue to update with bid/ask data, but that's all. I'm forced to kill the NT8 process via Task Manager because mouse clicks anywhere on NT menus are ignored.

    Here's some sample code that I call from OnRender() to fill a geometry with a variable SolidColorBrush, whose A, R, G, B values are calculated elsewhere. Am I doing something wrong?
    Code:
                    Brush tempBrush1 = new SolidColorBrush(Color.FromArgb((byte)ci_alpha, aby_red, 0, aby_blue));
                    tempBrush1.Freeze();
                    SharpDX.Direct2D1.Brush brushDXbid = tempBrush1.ToDxBrush(RenderTarget);
                    SharpDX.Vector2[] vectors1 = new []  {ap_bid1.ToVector2(), ap_bid2.ToVector2(), ap_bid3.ToVector2() };
                    SharpDX.Direct2D1.PathGeometry geo1 = new SharpDX.Direct2D1.PathGeometry(Core.Globals.D2DFactory);
                    SharpDX.Direct2D1.GeometrySink sink1 = geo1.Open();
                    sink1.BeginFigure(ap_bid0.ToVector2(), SharpDX.Direct2D1.FigureBegin.Filled);
                    sink1.AddLines(vectors1);
                    sink1.EndFigure(SharpDX.Direct2D1.FigureEnd.Closed);
                    sink1.Close();
                    RenderTarget.FillGeometry(geo1, brushDXbid);
                    geo1.Dispose();
                    sink1.Dispose();
                    brushDXbid.Dispose();

    #2
    Hello tradesmart,

    Thank you for your post.

    I do not see anything that would specifically cause the error or the exception. I believe the exception is referring to the SharpDX library when it refers to external component.

    I do not see a need for the tempBrush to freeze but I do not have the full context of the code. Is this a script you can provide or can you create a test script that recreates the same behavior?
    Are the only brushes created those that are shown in your code in your initial post?

    Comment


      #3
      Originally posted by NinjaTrader_PatrickH View Post
      Hello tradesmart,

      Thank you for your post.

      I do not see anything that would specifically cause the error or the exception. I believe the exception is referring to the SharpDX library when it refers to external component.

      I do not see a need for the tempBrush to freeze but I do not have the full context of the code. Is this a script you can provide or can you create a test script that recreates the same behavior?
      Are the only brushes created those that are shown in your code in your initial post?
      The chart using the code I provided is one of 3 tabs in a chart window. In addition to that window, the workspace contains two other charts, a SuperDOM, two T&S windows, an Alert window, a Basic Entry window, a Data Box and a NinjaScript Output window plus the Control Center. There's a lot going on with Tick Replay, OnRender and OnMarketData in 3 of the charts.

      The "external component" error I can narrow down to a single chart and indicator because of my try/catch code. The "Data.ColorSeries.Set" error could be from anywhere, since my code is not catching it. My assumption, perhaps unwarranted, is that it's also coming from my most brush-intensive indicator, whose sample code I provided earlier. That code gets called from OnRender() in a foreach loop that iterates through each price on each visible bar to calculate colors and geometry, among other things.

      Within that outer foreach loop, there's a nested foreach loop that marks the bar's POC with an ellipse. This code uses a couple of serialized brushes surfaced as properties. Here's the essence of that OnRender() code:
      Code:
      SharpDX.Vector2             vectorForEllipse ;
      SharpDX.Direct2D1.Ellipse    ellipse ;
      SharpDX.Direct2D1.Brush        ellipseBrushDX = null ;
      float    f_ypoc = (float)chartScale.GetYByValueWpf(cd_poc);
      Point    p_vpoc = new Point(f_barxpos, f_ypoc);
      ellipse = new SharpDX.Direct2D1.Ellipse(vectorForEllipse, 
                                              (float)cd_barspace/2f, f_height/2f);
      ellipseBrushDX = POCBrush.ToDxBrush(RenderTarget);
      RenderTarget.DrawEllipse(ellipse, ellipseBrushDX, POCBrushWidth);
      ...
      if (ellipseBrushDX != null) ellipseBrushDX.Dispose() ;

      Comment


        #4
        Hello,

        Thank you for the reply.

        Regarding the ColorSeries error, this could be caused by an indicator you have imported or one you have developed, without knowing which item is creating the error it is hard to say why it is being generated. The error message gives a clue that the ColorSeries has too many indexes. This may be instead a BrushSeries, ColorSeries was used in NT7 and Brush naming is used throughout NT8, potentially this is a mis labeled error. Do any of the scripts you have created use a BrushSeries?


        As for the second error, out of context it is hard to say what may be happening with the information you have provided so far.

        At this point I could suggest to refine the number of items in the workspace to see if a specific item is causing the error. If a specific item is found to be causing the error, we could review the source code used and the steps you provide to reproduce the error to see what may be occurring.

        Without being able to compile the syntax to check if that specific syntax does cause an error, I could only guess if this is the cause or not based on the description.

        Additionally I would not suggest using try/catch in NinjaScript. If you are having an exception with an area of code that requires try/catch due to a crash or freeze, you may need to instead review the syntax being used as the try catch could potentially hide the actual problems you are having. With SharpDX objects, if the Render can not continue because of a null reference or exception generated by one of those objects it could certainly cause a crash or exception at a lower level that can not be handled by the platform. SharpDX is a wrapper of the DirectX API, if some ninjascript object or logic is causing a lower level exception in SharpDX this can be more difficult to track down.


        I look forward to being of further assistance.
        JesseNinjaTrader Customer Service

        Comment


          #5
          I have isolated the code that logs the Data.ColorSeries.Set error in the trace file. My customized OnMarketData() calculates uptick and downtick ratios, then OnBarUpdate() plots the ratio correctly in Plots[4]. Trouble arises when it then attempts to adjust the color of the plot via PlotBrushes[4][0].

          If (Calculate == Calculate.OnEachTick || Calculate == Calculate.OnBarClose) the error appears in the trace file.

          If (Calculate == Calculate.OnPriceChange) no error appears. Even so, the colors do not conform to the values upon which they're based.

          In the following code called by OnBarUpdate(), DeltaPlotRatio is a bool property and RatioAtAsk is Plots[4].
          Code:
          if (DeltaPlotRatio && RatioAtAsk.IsValidDataPoint(0))
          {
              byte r, g, b ;
              double d_diff = cl_buycount - cl_sellcount ; 
              bool b_maxgreen = d_diff > 0 ;// true = green will be 255, red varies; false = red will be 255, green varies
              byte by_redshade    = (byte)(b_maxgreen ? (1-d_diff)*255.0 : 255) ;// adjusted red shade
              byte by_greenshade    = (byte)(b_maxgreen ? 255 : (1+d_diff)*255.0) ;// adjusted green shade
              byte by_b = (byte)(cd_pctdn * 100 >= HiliteThreshold || cd_pctup*100>=HiliteThreshold ? 0 
                  : ((Color)Plots[4].Brush.GetValue(SolidColorBrush.ColorProperty)).B) ;
              r = by_redshade ;
              g = by_greenshade ;
              b = by_b ;
              Brush brush_ratio = new SolidColorBrush(Color.FromArgb(255, r, g, b));
              brush_ratio.Freeze();
              PlotBrushes[4][0] = brush_ratio;
          }
          As for the other much more serious error (OnRender(): External component has thrown an exception), it happened only once and I have been unable to reproduce it. The reason I use try/catch is to convey more information about the method throwing the error. Without it, I would have no idea which indicator or method it was. Having that information, I've been running a workspace with a single chart containing only the indicator so identified, and, naturally, it works flawlessly for hours. Could there be some kind of bad interaction when multiple charts and indicators get added to the mix? I notice that when rendering trouble occurs, residual window remnants stick on the screen even after NT is no longer running. I can clear them only by maximizing some other window, like NotePad, to wipe the desktop clean.

          Comment


            #6
            I have now discovered that the trace file error in 8.0.0.12 is simply another manifestation of the PlotBrushes problem I reported last month for 8.0.0.11 in this thread: http://ninjatrader.com/support/forum...ad.php?t=86461

            The attached script demonstrates the issues encountered when using Tick Replay and Calculate.OnEachTick.
            Attached Files

            Comment


              #7
              Hello,

              Thank you for the reply.

              I reviewed the form post and it looks like there was an update regarding this topic in the other thread. The other post has been replied to with the solution to the ColorSeries error. It appears there are a few ways to choose from on how to solve it.

              Regarding the remainder of the questions.

              Could there be some kind of bad interaction when multiple charts and indicators get added to the mix? I notice that when rendering trouble occurs, residual window remnants stick on the screen even after NT is no longer running. I can clear them only by maximizing some other window, like NotePad, to wipe the desktop clean.
              Yes, there is the possibility that a script causing a problem on a chart could in turn affect how the other scripts function. It would be difficult to give any sort of example on this, but in the case that a script stops a charts core processes or halts its OnRender, that could lead to other items not being updated or having other logical problems.

              As far as the residual windows needing other windows to clear the screen, I have not had any reports of this for NT specifically but could potentially be caused by a driver issue with the graphics card. Have you checked to see if there are any updated drivers for your graphics card? Generally you can locate this information using the computer vendors support -> drivers page. If there are I would suggest trying that first to ensure the computer is completely up to date.

              I look forward to being of further assistance.
              JesseNinjaTrader Customer Service

              Comment


                #8
                Originally posted by NinjaTrader_Jesse View Post
                Hello,

                Thank you for the reply.

                I reviewed the form post and it looks like there was an update regarding this topic in the other thread. The other post has been replied to with the solution to the ColorSeries error. It appears there are a few ways to choose from on how to solve it.

                Regarding the remainder of the questions.



                Yes, there is the possibility that a script causing a problem on a chart could in turn affect how the other scripts function. It would be difficult to give any sort of example on this, but in the case that a script stops a charts core processes or halts its OnRender, that could lead to other items not being updated or having other logical problems.

                As far as the residual windows needing other windows to clear the screen, I have not had any reports of this for NT specifically but could potentially be caused by a driver issue with the graphics card. Have you checked to see if there are any updated drivers for your graphics card? Generally you can locate this information using the computer vendors support -> drivers page. If there are I would suggest trying that first to ensure the computer is completely up to date.

                I look forward to being of further assistance.
                I'm wondering if calling base.OnRender() unnecessarily could cause problems. That call was left over from an earlier version of my indicator that had a plot. I removed the plot but not the base.OnRender(). Now I have removed it and, so far, the chart has been running just fine for a couple of hours.

                Comment

                Latest Posts

                Collapse

                Topics Statistics Last Post
                Started by yertle, Yesterday, 08:38 AM
                7 responses
                28 views
                0 likes
                Last Post yertle
                by yertle
                 
                Started by bmartz, 03-12-2024, 06:12 AM
                2 responses
                20 views
                0 likes
                Last Post bmartz
                by bmartz
                 
                Started by funk10101, Today, 12:02 AM
                0 responses
                4 views
                0 likes
                Last Post funk10101  
                Started by gravdigaz6, Yesterday, 11:40 PM
                1 response
                8 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Started by MarianApalaghiei, Yesterday, 10:49 PM
                3 responses
                10 views
                0 likes
                Last Post NinjaTrader_Manfred  
                Working...
                X