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:
    [COLOR=Red][XmlIgnore()][/COLOR]
    [Description("Color for painted region")]
    [GridCategory("Parameters")]
    The second difference is in the next line of code:
    Code:
    public [COLOR=red]Color[/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.
    Josh P.NinjaTrader 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 jclose, Today, 09:37 PM
    0 responses
    4 views
    0 likes
    Last Post jclose
    by jclose
     
    Started by WeyldFalcon, 08-07-2020, 06:13 AM
    10 responses
    1,413 views
    0 likes
    Last Post Traderontheroad  
    Started by firefoxforum12, Today, 08:53 PM
    0 responses
    9 views
    0 likes
    Last Post firefoxforum12  
    Started by stafe, Today, 08:34 PM
    0 responses
    10 views
    0 likes
    Last Post stafe
    by stafe
     
    Started by sastrades, 01-31-2024, 10:19 PM
    11 responses
    169 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Working...
    X