Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Templates Malfunctioning

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

    Templates Malfunctioning

    Hey guys, I have a simple indicator which changes Color of EMA lines when the lines are far apart or too close together. The point is, the indicator works just fine when I apply it to a chart.

    The problem is: when I save a chart as a Template, and apply that template to any other chart the Indicators will stop changing color.

    World's leading screen capture + recorder from Snagit + Screencast by Techsmith. Capture, edit and share professional-quality content seamlessly.


    This happened before with other indicators but instead of NOT changing colors, It wouldn't let me set a Default color setting in the Indicator window. In other words, after I apply an indicator to a Chart ---> I change the color of the plot --> I set it to Default --> I try apply it to another chart, and the Colors appeared Transparent.


    is there something with Templates and Defaults that can be causing these problems. what can I do to fix it.

    #2
    Hello,

    Thank you for the question.

    In order to use colors in a user editable field you will need to change the public properties a little bit to make the colors serializable.

    There is a sample here: http://www.ninjatrader.com/support/f...ead.php?t=4977

    What is happeneing is that when the template is stored in XML, the object that is being stored (color) can not be converted into text for xml.

    What needs to happen is the existing public property that is your color needs to be ignored from being serialized and deserialized.

    Next you need to create a second public property that will be serialized and deserialized, and also sets your current public property to a color. This property when being serialized gets the value of your color and saves to xml, when it deserializes it reads the xml color and sets the color of your color property.

    This would be a complete color property:

    Code:
     //variables
    private Color borderColor = Color.Blue;
    
    //properties
    [XmlIgnore()] // important, ignores serialization 
    [Description("Color for painted region")]
    [GridCategory("Parameters")]
    public Color BorderColor
     {
          get { return borderColor; }
          set { borderColor = value; }
     }
    		
    // Serialize our Color object
    [Browsable(false)] // makes this not show in the indicators properties menu
    public string BorderColorSerialize
    {
    	get { return NinjaTrader.Gui.Design.SerializableColor.ToString(borderColor); }
    	set { borderColor = NinjaTrader.Gui.Design.SerializableColor.FromString(value); }
    }
    Please let me know if I may be of additional assistance.

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by argusthome, 03-08-2026, 10:06 AM
    0 responses
    89 views
    0 likes
    Last Post argusthome  
    Started by NabilKhattabi, 03-06-2026, 11:18 AM
    0 responses
    48 views
    0 likes
    Last Post NabilKhattabi  
    Started by Deep42, 03-06-2026, 12:28 AM
    0 responses
    31 views
    0 likes
    Last Post Deep42
    by Deep42
     
    Started by TheRealMorford, 03-05-2026, 06:15 PM
    0 responses
    34 views
    0 likes
    Last Post TheRealMorford  
    Started by Mindset, 02-28-2026, 06:16 AM
    0 responses
    69 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Working...
    X