Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Adding a User Defined Brush to the Color Picker

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

    Adding a User Defined Brush to the Color Picker

    I've got a problem adding a user defined brush to the color picker for an indicator.
    I get a cannot save xml error when I close the indicator.

    I have used your example to add the property :

    [CustomBrush]
    public Brush MyBrush
    {
    get { return new SolidColorBrush(Color.FromRgb(25, 175, 185)); }
    set { }
    }


    private Brush chartBackgroundColor = Brushes.Green;

    From the indicator window I set MyBrush to chartBackgroundColor.

    When I close the indicator I get the error message.



    #2
    Hello blar58,

    Thank you for the question.

    In this case the format of the property you provided is not correct. You would need a second property which serializes the brush and this property needs to be marked to not be serialized. We have a sample of this concept in the following link:


    https://ninjatrader.com/support/help...definedbrushes

    A more simple way to have the platform generate this for you is to use the indicator wizard to make the brush properties and then copy/paste the resulting syntax into your script.

    From the NinjaScript editor, click the Plus button in the lower left and select Indicator.
    Select Inputs and parameters
    Click Add
    Select the type as Brush and enter the values you want.
    Click Ok then Generate

    In the file that opens you will find the brush syntax for an input, you can close the file without saving it to discard it when done. The correct brush syntax looks like the following:


    Code:
    [NinjaScriptProperty]
    [XmlIgnore]
    [Display(Name="Test", Order=1, GroupName="Parameters")]
    public Brush Test
    { get; set; }
    
    [Browsable(false)]
    public string TestSerializable
    {
        get { return Serialize.BrushToString(Test); }
        set { Test = Serialize.StringToBrush(value); }
    }

    I look forward to being of further assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by charlesugo_1, 05-26-2026, 05:03 PM
    0 responses
    70 views
    0 likes
    Last Post charlesugo_1  
    Started by DannyP96, 05-18-2026, 02:38 PM
    1 response
    152 views
    0 likes
    Last Post NinjaTrader_ChelseaB  
    Started by CarlTrading, 05-11-2026, 05:56 AM
    0 responses
    162 views
    0 likes
    Last Post CarlTrading  
    Started by CarlTrading, 05-10-2026, 08:12 PM
    0 responses
    100 views
    0 likes
    Last Post CarlTrading  
    Started by Hwop38, 05-04-2026, 07:02 PM
    0 responses
    288 views
    0 likes
    Last Post Hwop38
    by Hwop38
     
    Working...
    X