Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Building Property Grid in State.Configure

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

    Building Property Grid in State.Configure

    I am trying to build the property grid from class members as opposed to typing all of it out. I created a class called Symbol and added property controls to it. Then in State.Configure, I am trying to create a Class instance for each Comma Separated Value the user gives in a control that is not inside the class. For example:

    Code:
    namespace NinjaTrader.NinjaScript.Indicators
    {
        public class AttributeTest : Indicator
        {
            public class Symbol{
                 public Symbol(string ticker,int labelTextAdjustment){
                    Ticker = ticker;
                    LabelTextAdjustment = labelTextAdjustment;
                }              
    
                public string Ticker
                {get; set;}
    
                [Display(Name = "Draw Label", Order = 1, GroupName = Ticker)]
                  public bool DrawLabel
                { get; set; }
    
                [Range(-2, 4)]
                [Display(Name="Label Text Adjustment", Order=2, GroupName=Ticker)]
                public int LabelTextAdjustment
                { get; set; }
            }
    
    
            public Dictionary<string, Symbol> symbols = new Dictionary<string, Symbol>();
    
            protected override void OnStateChange()
            {
                if (State == State.SetDefaults)
                {
                    Description                = NinjaTrader.Custom.Resource.NinjaScriptIndicatorDescriptionBuySellVolume;
                    Name                    = "AttributeTest";
                    Calculate                = Calculate.OnEachTick;
    
                }
                else if (State == State.Configure)
                {
                    string[] values = Symbols.Split(',');
                    //for each ticker the user gave, create a class for it and add the data series
                    foreach (string ticker in values)
                    {
                        ticker.Trim();                    
                        AddDataSeries(ticker,BarsPeriodType.Minute,1);
                        symbols.Add(ticker,new Symbol(ticker,2));
                    }
    
                }            
            }
    
            #region Properties
            [NinjaScriptProperty]
            [Display(Name="Symbols(comma separated)", Description="Comma Separated Symbols List", Order=0, GroupName="Parameters")]
            public string Symbols
            { get; set; }        
            #endregion        
    
        }
    }
    Is this possible? If so, can you give me a push in the right direction? Here is the error I am getting:
    Code:
    An object reference is required for the non-static field, method, or property.
    I get that error for each of these lines:
    Code:
    [Display(Name = "Draw Label", Order = 1, GroupName = Ticker)]
    Code:
    [Display(Name="Label Text Adjustment", Order=2, GroupName=Ticker)]

    #2
    Hello swcooke,

    Adding custom classes is beyond what is documented in the help guide.

    And public variables in that custom class are not going to appear in the Indicator parameters window.

    I think the attribute tags need to be taken off since these are not going to be user inputs.
    Chelsea B.NinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

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