Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Platform crashes because of brushes

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

    Platform crashes because of brushes

    Hello!
    Here is the story.
    I intend to develop an indicator that will require brushes.

    The problem is that when I compile the code below, I have no error message. Notice! In the "#region Properties", I have almost the same for each color ( I have represented the properties only for two of ten brushes). Only the names change.
    But when I go to the chart and when I want to add this indicator to the chart, the tab gets frozen for couple of seconds and than the platform just crushes.
    I have removed nine (9) colors (brushes) and remained with only one. After compiling, while trying to add the indicator to the chart, there is no problem.

    Trying to add the indicator on the chart was just a way to see how the window related to the setup on this indicator could look like and also if I have all properties in place. Of course with this code there is nothing to be seen on the chart.

    Why does the platform not crash with one color, but when I have all these ten colors the platform crashes?

    I would appreciate any help!

    Thanks in advance.

    Followed is the code.
    HTML Code:
    using System.Globalization;
    
    using System.Net;
    using System.IO;
    using System.IO.Compression;
    using System.Net.Cache;
    using System.Xml;
    using System.Text;
    using SharpDX;
    using SharpDX.DirectWrite;
    using SharpDX.Direct2D1;​
    HTML Code:
    public class MyIndicator : Indicator
        {
            #region Variables​
             private System.Windows.Media.Brush    color1;
             private System.Windows.Media.Brush    color2;
             private System.Windows.Media.Brush    color3;
             private System.Windows.Media.Brush    color4;
             private System.Windows.Media.Brush    color5;
             private System.Windows.Media.Brush    color6;
             private System.Windows.Media.Brush    color7;
             private System.Windows.Media.Brush    color8;
             private System.Windows.Media.Brush    color9;
             private System.Windows.Media.Brush    color10;
            #endregion
    }​

    HTML Code:
    protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {​
                   Color1                            = System.Windows.Media.Brushes.DarkSlateGray;
                    Color2                        = System.Windows.Media.Brushes.SeaGreen;
                    Color3                       = System.Windows.Media.Brushes.Green;
                    Color4                        = System.Windows.Media.Brushes.LimeGreen;
                    Color5                        = System.Windows.Media.Brushes.OliveDrab;
                    Color6                          = System.Windows.Media.Brushes.Indigo;
                    Color7                      = System.Windows.Media.Brushes.Orchid;
                    Color8                       = System.Windows.Media.Brushes.Crimson;
                    Color9                            = System.Windows.Media.Brushes.Red;
                    Color10                        = System.Windows.Media.Brushes.DarkOrange;
    }
       }​

    HTML Code:
    protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
            {
                base.OnRender(chartControl, chartScale);​
    
    
                SharpDX.Direct2D1.Brush color1Dx;
                SharpDX.Direct2D1.Brush color2Dx;
                SharpDX.Direct2D1.Brush color3Dx;
                SharpDX.Direct2D1.Brush color4Dx;
                SharpDX.Direct2D1.Brush color5Dx;
                SharpDX.Direct2D1.Brush color6Dx;
                SharpDX.Direct2D1.Brush color7Dx;
                SharpDX.Direct2D1.Brush color8Dx;
                SharpDX.Direct2D1.Brush color9Dx;
                SharpDX.Direct2D1.Brush color10Dx;​
    
    
                color1Dx     = color1.ToDxBrush(RenderTarget);
                color2Dx = color2.ToDxBrush(RenderTarget);
                color3Dx = color3.ToDxBrush(RenderTarget);
                color4Dx   = color4.ToDxBrush(RenderTarget);
                color5Dx = color5.ToDxBrush(RenderTarget);
                color6Dx      = color6.ToDxBrush(RenderTarget);
                color7Dx  = color7.ToDxBrush(RenderTarget);
                color8Dx  = color8.ToDxBrush(RenderTarget);
                color9Dx    = color9.ToDxBrush(RenderTarget);
                color10Dx  = color10.ToDxBrush(RenderTarget);
    
    
    
                color1Dx.Dispose();
                color2Dx.Dispose();
                color3Dx.Dispose();
                color4Dx.Dispose();
                color5Dx.Dispose();
                color6Dx.Dispose();
                color7Dx.Dispose();
                color8Dx.Dispose();
                color9Dx.Dispose();
                color10Dx.Dispose();  ​
    }​
    HTML Code:
                #region Properties
                [XmlIgnore]
            [Display(ResourceType = typeof(Custom.Resource), Name="Color1", Order=1, GroupName = "NinjaScriptGeneral")]
            public System.Windows.Media.Brush Color1
            {
                get { return color1; }
                set { color1 = value; }
            }
    
            [Browsable(false)]
            public string Color1Serialize
            {
                get { return Serialize.BrushToString(Color1); }
                set { Color1 = Serialize.StringToBrush(value); }
            }
    
             [XmlIgnore]
            [Display(ResourceType = typeof(Custom.Resource), Name="Color2", Order=2, GroupName = "NinjaScriptGeneral")]
            public System.Windows.Media.Brush Color2
            {
                get { return color2; }
                set { color2 = value; }
            }
    
            [Browsable(false)]
            public string Color2Serialize
            {
                get { return Serialize.BrushToString(Color2); }
                set { Color2 = Serialize.StringToBrush(value); }
            }​
    
    #endregion​
    Last edited by Stanfillirenfro; 05-22-2023, 01:56 PM.

    #2
    Hello Stanfillirenfro,

    Thank you for your post.

    Although you do not receive errors when compiling, do you see any errors in the Log tab of the Control Center?

    So I may accurately assist you, please answer all of the following questions:
    • Although you do not receive errors when compiling, do you see any errors in the Log tab of the Control Center?
      • If so, what do these errors report?
    • What version of NinjaTrader are you using? Please provide the entire version number. This can be found under Help -> About (Example: 8.?.?.?)

    I look forward to your reply.


    Comment


      #3
      Hello NinjaTrader_Emily and many thanks for your quick reply.

      Although you do not receive errors when compiling, do you see any errors in the Log tab of the Control Center?
      Emily I am not receiving any errors in the log tab. NONE!

      What version of NinjaTrader are you using?
      I am using the version 8.0.24.3

      Comment


        #4
        Hello Stanfillirenfro,

        Thank you for your reply.

        I see that you're using an older version of NinjaTrader Desktop. To update NinjaTrader to version 8.0.28.0 or 8.1.1.6, please visit the link below for steps on how to update to the latest version of NinjaTrader Desktop.

        Note: Updating NinjaTrader Desktop will not affect any custom configurations, workspaces, or add-ons.

        https://support.ninjatrader.com/s/ar...language=en_US
        Note: when logged into the portal, 8.1.1.6 will be listed as the most recent release and 8.0.28.0 may be found in the "Prior Releases" section on the right-hand side. For more details on the differences between both versions to help decide which version is right for you, please see the release notes here:Please test your script after updating the platform and advise if you are still able to reproduce the unexpected behavior of the platform crashing. I look forward to hearing the results.​

        Comment

        Latest Posts

        Collapse

        Topics Statistics Last Post
        Started by Geovanny Suaza, 02-11-2026, 06:32 PM
        0 responses
        602 views
        0 likes
        Last Post Geovanny Suaza  
        Started by Geovanny Suaza, 02-11-2026, 05:51 PM
        0 responses
        347 views
        1 like
        Last Post Geovanny Suaza  
        Started by Mindset, 02-09-2026, 11:44 AM
        0 responses
        103 views
        0 likes
        Last Post Mindset
        by Mindset
         
        Started by Geovanny Suaza, 02-02-2026, 12:30 PM
        0 responses
        560 views
        1 like
        Last Post Geovanny Suaza  
        Started by RFrosty, 01-28-2026, 06:49 PM
        0 responses
        559 views
        1 like
        Last Post RFrosty
        by RFrosty
         
        Working...
        X