• 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

  • NinjaTrader_JoshP
    started a topic User Definable Color Inputs

    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, 03:44 PM.

  • NinjaTrader_MichaelM
    replied
    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, 02:06 PM.

    Leave a comment:

Latest Posts

Collapse

Topics Statistics Last Post
Started by victorsmith, Today, 12:43 PM
1 response
16 views
0 likes
Last Post NinjaTrader_SergeyS  
Started by PN720, Today, 12:29 PM
2 responses
13 views
0 likes
Last Post PN720
by PN720
 
Started by traderpards, Today, 11:25 AM
1 response
6 views
0 likes
Last Post NinjaTrader_ChelseaB  
Started by bebbus, Today, 10:26 AM
7 responses
31 views
0 likes
Last Post NinjaTrader_PatrickG  
Started by GregoryBaskin, Today, 10:25 AM
1 response
6 views
0 likes
Last Post NinjaTrader_ChelseaB  
Working...
X