Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Parameter ordering

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

    Parameter ordering

    Hi

    I noticed that, event if you order your parameters correctly in the properties section, they are not in the attended order when the label display on the panel.
    Lets consider this declaration:

    Code:
            #region Properties
            [Range(1, int.MaxValue), NinjaScriptProperty]
            [Display(ResourceType = typeof(Custom.Resource), Name = "Min Period", GroupName = "NinjaScriptParameters", Order = 0)]
            public int MinPeriod
            { get; set; }
    
            [Range(1, int.MaxValue), NinjaScriptProperty]
            [Display(ResourceType = typeof(Custom.Resource), Name = "Middle Period", GroupName = "NinjaScriptParameters", Order = 1)]
            public int MiddlePeriod
            { get; set; }
    
            [Range(1, int.MaxValue), NinjaScriptProperty]
            [Display(ResourceType = typeof(Custom.Resource), Name = "Max Period", GroupName = "NinjaScriptParameters", Order = 2)]
            public int MaxPeriod
            { get; set; }
    
            [Range(1, int.MaxValue), NinjaScriptProperty]
            [Display(ResourceType = typeof(Custom.Resource), Name = "EMA Period", GroupName = "NinjaScriptParameters", Order = 3)]
            public int PeriodEMA
            { get; set; }
            #endregion
    ​
    In the OnStateChange section:

    Code:
                    MinPeriod            = 13;
                    MiddlePeriod        = 21;
                    MaxPeriod            = 34;
                    
                    PeriodEMA            = 3;
    ​
    Here is the result:

    Click image for larger version

Name:	Capture.jpg
Views:	80
Size:	2.2 KB
ID:	1318760


    Did I miss something ?

    #2
    Hi Philippe56140,

    We notice that the parameters are sorted in alphabetical order. You can rename the parameters to sort them in the desired order.

    Regards,
    William
    ninZa
    NinjaTrader Ecosystem Vendor - ninZa.co

    Comment


      #3
      Hello Philippe56140,

      ninZa is correct. The ordering for parameters in the Chart label is alphabetical.

      Comment


        #4
        I followed your advise, renaming the indicators properties name:

        Code:
                [Range(1, int.MaxValue), NinjaScriptProperty]
                [Display(ResourceType = typeof(Custom.Resource), Name = "1.Min Period", GroupName = "NinjaScriptParameters", Order = 0)]
                public int MinPeriod
                { get; set; }
        
                [Range(1, int.MaxValue), NinjaScriptProperty]
                [Display(ResourceType = typeof(Custom.Resource), Name = "2.Middle Period", GroupName = "NinjaScriptParameters", Order = 1)]
                public int MiddlePeriod
                { get; set; }
        
                [Range(1, int.MaxValue), NinjaScriptProperty]
                [Display(ResourceType = typeof(Custom.Resource), Name = "3.Max Period", GroupName = "NinjaScriptParameters", Order = 2)]
                public int MaxPeriod
                { get; set; }
        ​
        Everything is initialized in the State == State.SetDefaults section:

        Code:
                        MinPeriod            = 13;
                        MiddlePeriod        = 21;
                        MaxPeriod            = 34;
                        
        ​
        However, the displayed ordre is still incorrect:

        Click image for larger version

Name:	image.png
Views:	66
Size:	2.0 KB
ID:	1318923

        Comment


          #5
          Hi Philippe56140,

          Please refer to the code below:

          Code:
          #region Properties
          [Range(1, int.MaxValue), NinjaScriptProperty]
          [Display(ResourceType = typeof(Custom.Resource), Name = "Min Period", GroupName = "NinjaScriptParameters", Order = 0)]
          public int Property1_MinPeriod { get; set; }
          
          [Range(1, int.MaxValue), NinjaScriptProperty]
          [Display(ResourceType = typeof(Custom.Resource), Name = "Middle Period", GroupName = "NinjaScriptParameters", Order = 1)]
          public int Property2_MiddlePeriod { get; set; }
          
          [Range(1, int.MaxValue), NinjaScriptProperty]
          [Display(ResourceType = typeof(Custom.Resource), Name = "Max Period", GroupName = "NinjaScriptParameters", Order = 2)]
          public int Property3_MaxPeriod { get; set; }
          
          [Range(1, int.MaxValue), NinjaScriptProperty]
          [Display(ResourceType = typeof(Custom.Resource), Name = "EMA Period", GroupName = "NinjaScriptParameters", Order = 3)]
          public int Property4_PeriodEMA { get; set; }
          #endregion
          
          
          protected override void OnStateChange() {
              if (State == State.SetDefaults) {
                  Description = @"Enter the description for your new custom Indicator here.";
                  Name = "MyCustomIndicator11111";
                  Calculate = Calculate.OnBarClose;
                  IsOverlay = false;
                  DisplayInDataBox = true;
                  DrawOnPricePanel = true;
                  DrawHorizontalGridLines = true;
                  DrawVerticalGridLines = true;
                  PaintPriceMarkers = true;
                  ScaleJustification = NinjaTrader.Gui.Chart.ScaleJustification.Right;
                  //Disable this property if your indicator requires custom values that cumulate with each new market data event.
                  //See Help Guide for additional information.
                  IsSuspendedWhileInactive = true;
          
                  Property1_MinPeriod = 13;
                  Property2_MiddlePeriod = 21;
                  Property3_MaxPeriod = 34;
          
                  Property4_PeriodEMA = 3;
              }
          }
          Regards,
          William
          ninZa
          NinjaTrader Ecosystem Vendor - ninZa.co

          Comment

          Latest Posts

          Collapse

          Topics Statistics Last Post
          Started by Geovanny Suaza, 02-11-2026, 06:32 PM
          0 responses
          598 views
          0 likes
          Last Post Geovanny Suaza  
          Started by Geovanny Suaza, 02-11-2026, 05:51 PM
          0 responses
          343 views
          1 like
          Last Post Geovanny Suaza  
          Started by Mindset, 02-09-2026, 11:44 AM
          0 responses
          103 views
          0 likes
          Last Post Mindset
          by Mindset
           
          Started by Geovanny Suaza, 02-02-2026, 12:30 PM
          0 responses
          556 views
          1 like
          Last Post Geovanny Suaza  
          Started by RFrosty, 01-28-2026, 06:49 PM
          0 responses
          555 views
          1 like
          Last Post RFrosty
          by RFrosty
           
          Working...
          X