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

Any way to add dynamic(variable) inputs?

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

    Any way to add dynamic(variable) inputs?

    HI.
    at this moment, I always declare the inputs with fixed blocks, like:

    Code:
    	[Category("xyz")]
            [Display(Name = "InutName abc", Order = 1)]
            public bool Enable_Smth_1
            {
                get { return enable_smth[1]; }	set { enable_smth[1] = value; }
            }

    is it somehow possible to create the dynamic number of inputs, like:
    Code:
    for(var i=0; i<4; i++){
    
    	[Category("xyz"+i)]
            [Display(Name = "InutName abc"+i, Order = i)]
            public bool "Enable_Smth"+i
            {
                get { return enable_smth[i]; }	set { enable_smth[i] = value; }
            }
    
    }

    #2
    Hello,

    Thank you for the post.

    You could explore using Collections such as an Array if the user needs to input multiple choices. There is a sample here that contains a list of elements as a property: https://ninjatrader.com/support/foru...ad.php?t=97919

    Otherwise, I am unaware of a way to have any sort of looping logic like this outside of the method level in the class scope. There would not be anything I could personally suggest to make adding of properties more dynamic like you have shown. If any other users have explored this concept, they could certainly provide their solutions here.


    I look forward to being of further assistance.
    JesseNinjaTrader Customer Service

    Comment

    Latest Posts

    Collapse

    Topics Statistics Last Post
    Started by jclose, Today, 09:37 PM
    0 responses
    4 views
    0 likes
    Last Post jclose
    by jclose
     
    Started by WeyldFalcon, 08-07-2020, 06:13 AM
    10 responses
    1,413 views
    0 likes
    Last Post Traderontheroad  
    Started by firefoxforum12, Today, 08:53 PM
    0 responses
    9 views
    0 likes
    Last Post firefoxforum12  
    Started by stafe, Today, 08:34 PM
    0 responses
    10 views
    0 likes
    Last Post stafe
    by stafe
     
    Started by sastrades, 01-31-2024, 10:19 PM
    11 responses
    169 views
    0 likes
    Last Post NinjaTrader_Manfred  
    Working...
    X