• 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

User Definable Color Inputs

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

    User Definable Color Inputs

    Applies to NinjaTrader 7

    User definable inputs do not need to be limited to numeric values. You can have colors as an input as well. To do this you will need to make a public property for a Color object instead of an int or double.

    In the "Properties" region of your code, there is only a slight change in the code snippet you would normally use to create user definable inputs. You need an extra line above the Description field.
    Code:
    [XmlIgnore()]
    [Description("Color for painted region")]
    [GridCategory("Parameters")]
    The second difference is in the next line of code:
    Code:
    public Color PaintColor
    {
         get { return paintColor; }
         set { paintColor = value; }
    }
    This creates a color input for use in the dialog window when we try to add the NinjaScript to a chart.

    Some additional extra code that is required for creating a color input is to serialize the color. Serialization is necessary for NinjaTrader to use the color input throughout the program. Please note that serialization is a general concept not exclusive to color inputs. There may be other struct/classes (e.g. TimeSpan) that you could use in your code that would also need to have their "value" properties serialized.
    Code:
    [Browsable(false)]
    public string PaintColorSerialize
    {
         get { return NinjaTrader.Gui.Design.SerializableColor.ToString(paintColor); }
         set { paintColor = NinjaTrader.Gui.Design.SerializableColor.FromString(value); }
    }
    Attached is a NinjaScript indicator sample that uses two user definable color inputs to determine the color of a drawn rectangle.
    Attached Files
    Last edited by NinjaTrader_Jesse; 06-03-2015, 02:44 PM.
    JoshNinjaTrader Customer Service

    #2
    Applies to NinjaTrader 8

    User definable inputs do not need to be limited to numeric values. You can have brushes as an input as well. To do this you will need to make a public property for a Brush object instead of an int or double.

    In the "Properties" region of your code, there is only a slight change in the code snippet you would normally use to create user definable inputs.
    Code:
    [XmlIgnore()]
    [Display(Name = "BorderBrush", GroupName = "NinjaScriptParameters", Order = 0)]
    The second difference is in the next line of code:
    Code:
    public Brush BorderBrush
    { get; set; }
    This creates a brush input for use in the dialog window when we try to add the NinjaScript to a chart.

    Some additional extra code that is required for creating a color input is to serialize the brush. Serialization is necessary for NinjaTrader to use the brush input throughout the program. Please note that serialization is a general concept not exclusive to brush inputs. There may be other struct/classes (e.g. TimeSpan) that you could use in your code that would also need to have their "value" properties serialized.
    Code:
    [Browsable(false)]
    public string BorderBrushSerialize
    {
    	get { return Serialize.BrushToString(BorderBrush); }
       	set { BorderBrush = Serialize.StringToBrush(value); }
    }
    Attached is a NinjaScript indicator sample that uses two user definable brush inputs to determine the color of a drawn rectangle.
    Attached Files
    Last edited by NinjaTrader_MichaelM; 06-23-2015, 01:06 PM.
    Michael M.NinjaTrader Quality Assurance

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by brucerobinson, Today, 02:43 AM
    5 responses
    26 views
    0 likes
    Last Post brucerobinson  
    Started by 2Look4me, Today, 09:33 AM
    6 responses
    39 views
    0 likes
    Last Post NinjaTrader_PatrickH  
    Started by calebsandfort, Today, 02:11 PM
    2 responses
    8 views
    0 likes
    Last Post calebsandfort  
    Started by traderpards, Today, 02:16 PM
    1 response
    6 views
    0 likes
    Last Post NinjaTrader_Jim  
    Started by otislauwaert, Today, 12:59 PM
    1 response
    16 views
    0 likes
    Last Post NinjaTrader_Jim  
    Working...
    X