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 Mindset, 04-21-2026, 06:46 AM
    0 responses
    50 views
    0 likes
    Last Post Mindset
    by Mindset
     
    Started by M4ndoo, 04-20-2026, 05:21 PM
    0 responses
    69 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by M4ndoo, 04-19-2026, 05:54 PM
    0 responses
    36 views
    0 likes
    Last Post M4ndoo
    by M4ndoo
     
    Started by cmoran13, 04-16-2026, 01:02 PM
    0 responses
    97 views
    0 likes
    Last Post cmoran13  
    Started by PaulMohn, 04-10-2026, 11:11 AM
    0 responses
    60 views
    0 likes
    Last Post PaulMohn  
    Working...
    X