• 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 timcjpfx, Today, 01:18 PM
    1 response
    4 views
    0 likes
    Last Post NinjaTrader_Tyler  
    Started by lordvader34, Today, 12:48 PM
    2 responses
    11 views
    0 likes
    Last Post lordvader34  
    Started by Newtrader101, Today, 11:06 AM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_Jesse  
    Started by Newtrader101, Today, 11:03 AM
    2 responses
    9 views
    0 likes
    Last Post Newtrader101  
    Started by rickyblah12, Today, 09:57 AM
    1 response
    10 views
    0 likes
    Last Post NinjaTrader_PaulH  
    Working...
    X