• 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, 03: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, 02:06 PM.
    Michael M.NinjaTrader Quality Assurance

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by Leope, Today, 05:39 AM
    0 responses
    1 view
    0 likes
    Last Post Leope
    by Leope
     
    Started by memonic, Today, 05:14 AM
    0 responses
    1 view
    0 likes
    Last Post memonic
    by memonic
     
    Started by svadukia, Today, 04:38 AM
    0 responses
    1 view
    0 likes
    Last Post svadukia  
    Started by dadarara, Today, 04:19 AM
    0 responses
    2 views
    0 likes
    Last Post dadarara  
    Started by Shansen, Today, 04:13 AM
    0 responses
    2 views
    0 likes
    Last Post Shansen
    by Shansen
     
    Working...
    X