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

Category with enum on top

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

    Category with enum on top

    Hi,

    I've got a category with an enum input and 2 simple inputs. I'd like to have the whole category on top of the input window. I tried with GridCategory but I have an error on the enum series, while everything is fine using Category instead, but "MyParameters" is not on top:
    Code:
            [Description("")]
            [Category("MyParameters")]
    		[Gui.Design.DisplayNameAttribute("Delta Value ")]
            public int Deltavalue
            {
                get { return deltavalue; }
                set { deltavalue = Math.Max(1, value); }
            }
    		
    		[Description("")]
            [Category("MyParameters")]
    		[Gui.Design.DisplayNameAttribute("Implied Volatility ")]
            public double Implied
            {
                get { return implied; }
                set { implied = Math.Max(0, value); }
            }
    		
    		[Description("")]
    		[GridCategory("MyParameters")]
    		[Gui.Design.DisplayNameAttribute("Strategy")]
    		public StrategyType Strategy
    		{
    			get { return strategyType; }
    			set { strategyType = value;StrategySetting(); }
    		}
    is there a different way for ranking categories when using enum?

    Thanks

    #2
    Hello MAX,

    "GridCategory" should be the property that is used when using NinjaTrader 7 as "Category" was meant to be only used for NinjaTrader 6.5.

    NinjaTrader will list them alphabetically so if you would like to be at the top you may want to add a number before it like the following:

    Code:
    [Description("")]
    [GridCategory("MyParameters")]
    [Gui.Design.DisplayName("1. Strategy")]
    public StrategyType Strategy
    {
    	get { return strategyType; }
    	set { strategyType = value;StrategySetting(); }
    }
    JCNinjaTrader Customer Service

    Comment


      #3
      Probably my question wasn't so clear.

      If you see the picture, what I mean is that the whole category, named "MyParameters" should be translated on top of the input window.

      If I use GridCategory an error is returned on the following:

      Code:
                      [Description("")]
      		[GridCategory("MyParameters")]
      		[Gui.Design.DisplayNameAttribute("Strategy")]
      		public StrategyType Strategy
      		{
      			get { return strategyType; }
      			set { strategyType = value;StrategySetting(); }
      		}
      which is an enum input.

      If, otherwise, I use Category for all, no error is returned but the category "MyParameters" is showed in the middle of the input window.

      Hope this clear. Thanks.
      Attached Files

      Comment


        #4
        Hello MAX,

        Could you clarify what error that you get (in full) when you use "GridCategory" as that should be the syntax that you use in all of your variables when writing a NinjaScript file for NinjaTrader 7?

        Happy to be of further assistance.
        JCNinjaTrader Customer Service

        Comment


          #5
          Hi JC,

          following is my code.
          Please try it and see what happens.

          Thanks.
          Code:
          public class MyCustomIndicator : Indicator
              {
                  #region Variables
                  // Wizard generated variables
                      private int myInput0 = 1; // Default setting for MyInput0
                  // User defined variables (add any user defined variables below)
          		public enum StrategyType {Stgy_1,Stgy_2,Stgy_3};   
          		private StrategyType strategyType = StrategyType.Stgy_1;	
          		
          		
          		
                  #endregion
          
                  /// <summary>
                  /// This method is used to configure the indicator and is called once before any bar data is loaded.
                  /// </summary>
                  protected override void Initialize()
                  {
                      Add(new Plot(Color.FromKnownColor(KnownColor.Orange), PlotStyle.Line, "Plot0"));
                      Overlay				= false;
                  }
          
                  /// <summary>
                  /// Called on each bar update event (incoming tick)
                  /// </summary>
                  protected override void OnBarUpdate()
                  {
                      // Use this method for calculating your indicator values. Assign a value to each
                      // plot below by replacing 'Close[0]' with your own formula.
                      Plot0.Set(Close[0]);
                  }
          
                  #region Properties
                  [Browsable(false)]	// this line prevents the data series from being displayed in the indicator properties dialog, do not remove
                  [XmlIgnore()]		// this line ensures that the indicator can be saved/recovered as part of a chart template, do not remove
                  public DataSeries Plot0
                  {
                      get { return Values[0]; }
                  }
          
                  [Description("")]
                  [GridCategory("Parameters")]
                  public int MyInput0
                  {
                      get { return myInput0; }
                      set { myInput0 = Math.Max(1, value); }
                  }
          		
          		[Description("Choose strategy.")]
          		[GridCategory("MyParameters")]
          		[Gui.Design.DisplayNameAttribute("Strategy")]
          		public StrategyType Strategy
          		{
          			get { return strategyType; }
          			set { strategyType = value;}
          		}
          		
          		
                  #endregion
              }

          Comment


            #6
            Hello MAX,

            Thanks for the sample code.

            This is going to be due to defining the enum type inside of the class. You may want to define it outside of the class so that you do not get these compile errors. For example:

            Code:
            public enum StrategyType {Stgy_1,Stgy_2,Stgy_3};   
            
            // This namespace holds all indicators and is required. Do not change it.
            namespace NinjaTrader.Indicator
            {
                [Description("Enter the description of your new custom indicator here")]
                public class MyCustomIndicator : Indicator
                {		
            		private StrategyType strategyType = StrategyType.Stgy_1;	
            
            		[Description("Choose strategy.")]
            		[GridCategory("Parameters")]
            		[Gui.Design.DisplayNameAttribute("Strategy")]
            		public StrategyType Strategy
            		{
            			get { return strategyType; }
            			set { strategyType = value;}
            		}	
                }
            }
            JCNinjaTrader Customer Service

            Comment


              #7
              Thanks JC, it does the work perfectly.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by WHICKED, Today, 12:45 PM
              2 responses
              19 views
              0 likes
              Last Post WHICKED
              by WHICKED
               
              Started by GussJ, 03-04-2020, 03:11 PM
              15 responses
              3,276 views
              0 likes
              Last Post Leafcutter  
              Started by Tim-c, Today, 02:10 PM
              1 response
              8 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by Taddypole, Today, 02:47 PM
              0 responses
              5 views
              0 likes
              Last Post Taddypole  
              Started by chbruno, 04-24-2024, 04:10 PM
              4 responses
              51 views
              0 likes
              Last Post chbruno
              by chbruno
               
              Working...
              X