Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 algospoke, Yesterday, 06:40 PM
    2 responses
    19 views
    0 likes
    Last Post algospoke  
    Started by ghoul, Today, 06:02 PM
    3 responses
    14 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by jeronymite, 04-12-2024, 04:26 PM
    3 responses
    45 views
    0 likes
    Last Post jeronymite  
    Started by Barry Milan, Yesterday, 10:35 PM
    7 responses
    21 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Started by AttiM, 02-14-2024, 05:20 PM
    10 responses
    181 views
    0 likes
    Last Post jeronymite  
    Working...
    X