• 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

Color as a parameter

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

    Color as a parameter

    Hi.
    I want to be able to set bar color from an input parameter. I have tried -

    variables
    private Color buyBarColor = Color.Blue;

    Properties
    [Description("Color for Buy Bars")]
    [GridCategory("Parameters")]
    public Color BuyBarColor
    {
    get { return buyBarColor; }
    set { buyBarColor = value; }
    }

    I get a nice blue colored box in the indicator parameters section, and the
    bars are colored blue by BarColor = BuyBarColor;. Any color can be chosen at this point but when Ninja is closed and re-opened, the blue setting (or whatever color was set) has been lost.
    Is there any solution to this please?
    Dave

    #2
    Hello DaveS,

    Thank you for your post.

    There is a second segment of code that would need to be used for these to serialize property when saving your workspace.

    Please try adding the following below your current code:

    Code:
    [Browsable(false)] 
    public string BuyBarColorSerialize
    {      
    get { return NinjaTrader.Gui.Design.SerializableColor.ToString(buyBarColor); }      
    set { buyBarColor = NinjaTrader.Gui.Design.SerializableColor.FromString(value); }
    
     }
    Please see our Reference Sample on User Definable Color Inputs for more information:

    http://www.ninjatrader.com/support/f...ead.php?t=4977
    MatthewNinjaTrader Product Management

    Comment


      #3
      Color as Parameter

      Hallo, I' m sorry but this code doesn't work:
      /// <summary>
      /// </summary>
      [XmlIgnore]
      [Description("Select Color for TargetLineColor")]
      [Category("Parameters")]
      [Gui.Design.DisplayName("TargetLineColor")]
      public Color TargetLineColor
      {
      get { return targetLineColor; }
      set { targetLineColor = value; }
      }

      // Serialize Color object
      [Browsable(false)]
      public string TargetLineColorSerialize
      {
      get { returnNinjaTrader.Gui.Design.SerializableColor.ToS tring(targetLineColor);}
      set { targetLineColor = NinjaTrader.Gui.Design.SerializableColor.FromStrin g(value); }
      }

      Thanks Rolf Theus

      Comment


        #4
        Hello RolfTheus,

        Welcome to the NinjaTrader Support Forums!

        I see a few formatting errors that may be causing issues.

        Originally posted by RolfTheus View Post
        Hallo, I' m sorry but this code doesn't work:
        /// <summary>
        /// </summary>
        [XmlIgnore]
        [Description("Select Color for TargetLineColor")]
        [Category("Parameters")]
        [Gui.Design.DisplayName("TargetLineColor")]
        public Color TargetLineColor
        {
        get { return targetLineColor; }
        set { targetLineColor = value; }
        }

        // Serialize Color object
        [Browsable(false)]
        public string TargetLineColorSerialize
        {
        get { returnNinjaTrader.Gui.Design.SerializableColor.ToS tring(targetLineColor);}
        set { targetLineColor = NinjaTrader.Gui.Design.SerializableColor.FromStrin g(value); }
        }

        Thanks Rolf Theus
        There are a few spaces and one in need of a space that will be causing issues. You may see the following code below:

        Code:
        		[XmlIgnore]
        		[Description("Select Color for TargetLineColor")]
        		[Category("Parameters")]
        		[Gui.Design.DisplayName("TargetLineColor")]
        		public Color TargetLineColor
        		{
        		get { return targetLineColor; }
        		set { targetLineColor = value; }
        		}
        
        		// Serialize Color object
        		[Browsable(false)]
        		public string TargetLineColorSerialize
        		{
        		get { return NinjaTrader.Gui.Design.SerializableColor.ToString(targetLineColor);} 
        		set { targetLineColor = NinjaTrader.Gui.Design.SerializableColor.FromString(value); }
        		}
        Coding is very case and format sensitive, you may view the following link from our Help Guide that goes over some tutorials and concepts at the following link.
        http://www.ninjatrader.com/support/h..._resources.htm

        Let us know if we can be of further assistance.
        JCNinjaTrader Customer Service

        Comment


          #5
          Thank you for answering, but the spaces are product of copying. I tried to format the code in the Messagearea. I could compile my code. I have copied your code, and now it works fine. But what is the difference except the spaces ? I don't know.

          Thanks
          Rolf Theus

          Comment


            #6
            Hello RolfTheus,

            I did not change anything inside the code that you posted besides add a space between "return" and "NinjaTrader.Gui(...)", remove the space between the "ToS" and "tring" in the same line, and remove the space between "FromStrin" and "g" in the next line.
            JCNinjaTrader Customer Service

            Comment

            Latest Posts

            Collapse

            Topics Statistics Last Post
            Started by Moody1337, Today, 09:50 AM
            1 response
            4 views
            0 likes
            Last Post NinjaTrader_ChelseaB  
            Started by ballboy11, Today, 09:45 AM
            1 response
            2 views
            0 likes
            Last Post NinjaTrader_ChrisL  
            Started by Moody1337, Today, 09:25 AM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_Heath  
            Started by franco12364, Today, 08:59 AM
            1 response
            6 views
            0 likes
            Last Post NinjaTrader_Kate  
            Started by kweiss, Yesterday, 08:35 PM
            1 response
            8 views
            0 likes
            Last Post NinjaTrader_Jesse  
            Working...
            X