• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

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.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by ttodua, Today, 01:12 AM
    2 responses
    17 views
    0 likes
    Last Post ttodua
    by ttodua
     
    Started by kujista, Today, 02:57 PM
    1 response
    7 views
    0 likes
    Last Post NinjaTrader_Kate  
    Started by henord, Today, 02:40 PM
    6 responses
    18 views
    0 likes
    Last Post NinjaTrader_RyanS  
    Started by Johnny Santiago, Today, 01:57 PM
    1 response
    11 views
    0 likes
    Last Post NinjaTrader_RyanS  
    Started by Bigbear57, Today, 01:37 PM
    1 response
    8 views
    0 likes
    Last Post NinjaTrader_RyanS  
    Working...
    X