Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

Partner 728x90

Collapse

Tip: How to exclude visual settings from the parameter list of an indicator?

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

    Tip: How to exclude visual settings from the parameter list of an indicator?

    When you develop a custom indicator, some of the properties determine its behavior, for example, the period for a moving average. Some of them determine how it plots, for example, the color of an arrow. Many of us add an attribute, [Categogy("Parameters")], to the properties so that they will display together in the "Parameters" section in the Indicator dialog box, separate from the "General" section. Pretty neat! We pat ourselves on the shoulders.

    However, the auto-generated construstor for your indicator now have all the properties as parameters. To use your indicator in a strategy or another indicator, you are forced to set all the parameters even though you do not care about the visual aspect of the indicator under the occassion. For example, you want to type MyMA(period) instead of MyMA(period, Color.Red). If your indicator has quite a few visual settings, it becomes annoying quickly.

    What can we do? We have no control over how the constructors are generated, right? Well, not directly. My experiment shows that Parameters is a special category name. The NinjaScript compiler inspects your code and adds every property with that attribute to the list of parameters for the constructor.

    Actually, you can come up with any category name to use. For example, if you add [Categogy("Visual")] to all the properties related to plotting, they will all display in a "Visual" section in the Indicator dialog box. And...they all disapper from the contructor's parameter list! You can type MyMA(period) to your heart's content. Now that's neat!
    Last edited by KamaCoder Eric; 05-21-2008, 04:53 PM.

    #2
    Originally posted by KamaCoder Eric View Post
    When you develop a custom indicator, some of the properties determine its behavior, for example, the period for a moving average. Some of them determine how it plots, for example, the color of an arrow. Many of us add an attribute, [Categogy("Parameters")], to the properties so that they will display together in the "Parameters" section in the Indicator dialog box, separate from the "General" section. Pretty neat! We pat ourselves on the shoulders.

    However, the auto-generated construstor for your indicator now have all the properties as parameters. To use your indicator in a strategy or another indicator, you are forced to set all the parameters even though you do not care about the visual aspect of the indicator under the occassion. For example, you want to type MyMA(period) instead of MyMA(period, Color.Red). If your indicator has quite a few visual settings, it becomes annoying quickly.

    What can we do? We have no control over how the constructors are generated, right? Well, not directly. My experiment shows that Parameters is a special category name. The NinjaScript compiler inspects your code and adds every property with that attribute to the list of parameters for the constructor.

    Actually, you can come up with any category name to use. For example, if you add [Categogy("Visual")] to all the properties related to plotting, they will all display in a "Visual" section in the Indicator dialog box. And...they all disapper from the contructor's parameter list! You can type MyMA(period) to your heart's content. Now that's neat!
    Hi, Is there a way to do that in the strategies?.

    Regards

    Comment


      #3
      Yes you can. Done the same way.
      Josh P.NinjaTrader Customer Service

      Comment


        #4
        Originally posted by Josh View Post
        Yes you can. Done the same way.
        I try to do it on strategies but I can not, What I'm doing wrong? Attach is the complete code in case you need to take a look.


        #region Properties
        /// <summary>
        /// </summary>
        [Description("Period for fast MA")]
        [Category("My Parameters")]
        public int Fast
        {
        get { return fast; }
        set { fast = Math.Max(1, value); }
        }

        /// <summary>
        /// </summary>
        [Description("Period for slow MA")]
        [Category("My Own Parameters")]
        public int Slow
        {
        get { return slow; }
        set { slow = Math.Max(1, value); }
        }
        #endregion
        Attached Files

        Comment


          #5
          Guys, setting anything else than "Parameter" in the category attribute on properties is not supported. It may or may not work as expected for indicators or strategies. You'd need to find out by yourself. In any case this is beyond what we can provide support for.

          Thanks for your understanding.

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by inanazsocial, Today, 01:15 AM
          1 response
          6 views
          0 likes
          Last Post NinjaTrader_Jason  
          Started by rocketman7, Today, 02:12 AM
          0 responses
          10 views
          0 likes
          Last Post rocketman7  
          Started by dustydbayer, Today, 01:59 AM
          0 responses
          2 views
          0 likes
          Last Post dustydbayer  
          Started by trilliantrader, 04-18-2024, 08:16 AM
          5 responses
          23 views
          0 likes
          Last Post trilliantrader  
          Started by Davidtowleii, Today, 12:15 AM
          0 responses
          3 views
          0 likes
          Last Post Davidtowleii  
          Working...
          X