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 Geovanny Suaza, 02-11-2026, 06:32 PM
    0 responses
    666 views
    0 likes
    Last Post Geovanny Suaza  
    Started by Geovanny Suaza, 02-11-2026, 05:51 PM
    0 responses
    377 views
    1 like
    Last Post Geovanny Suaza  
    Started by Mindset, 02-09-2026, 11:44 AM
    0 responses
    110 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by Geovanny Suaza, 02-02-2026, 12:30 PM
    0 responses
    575 views
    1 like
    Last Post Geovanny Suaza  
    Started by RFrosty, 01-28-2026, 06:49 PM
    0 responses
    580 views
    1 like
    Last Post RFrosty
    by RFrosty
     
    Working...
    X