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

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 lorem, Today, 09:18 AM
    1 response
    4 views
    0 likes
    Last Post lorem
    by lorem
     
    Started by bmartz, Today, 09:30 AM
    0 responses
    1 view
    0 likes
    Last Post bmartz
    by bmartz
     
    Started by GussJ, 03-04-2020, 03:11 PM
    14 responses
    3,244 views
    0 likes
    Last Post GussJ
    by GussJ
     
    Started by ArkansasClint, Today, 09:28 AM
    0 responses
    0 views
    0 likes
    Last Post ArkansasClint  
    Started by hazylizard, Today, 08:38 AM
    4 responses
    12 views
    0 likes
    Last Post hazylizard  
    Working...
    X