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.

    http://screencast.com/t/Ui0TITx1

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

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by jc.am, Today, 07:59 PM
    0 responses
    2 views
    0 likes
    Last Post jc.am
    by jc.am
     
    Started by i2w8am9ii2, Today, 04:36 PM
    2 responses
    13 views
    0 likes
    Last Post i2w8am9ii2  
    Started by WeyldFalcon, Today, 02:07 PM
    2 responses
    14 views
    0 likes
    Last Post WeyldFalcon  
    Started by hfwiley, Today, 03:02 PM
    2 responses
    19 views
    0 likes
    Last Post hfwiley
    by hfwiley
     
    Started by pdennis, Today, 02:34 PM
    3 responses
    21 views
    0 likes
    Last Post NinjaTrader_ChrisL  
    Working...
    X