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 zstheorist, Today, 07:52 PM
    0 responses
    3 views
    0 likes
    Last Post zstheorist  
    Started by pmachiraju, 11-01-2023, 04:46 AM
    8 responses
    149 views
    0 likes
    Last Post rehmans
    by rehmans
     
    Started by mattbsea, Today, 05:44 PM
    0 responses
    5 views
    0 likes
    Last Post mattbsea  
    Started by RideMe, 04-07-2024, 04:54 PM
    6 responses
    33 views
    0 likes
    Last Post RideMe
    by RideMe
     
    Started by tkaboris, Today, 05:13 PM
    0 responses
    5 views
    0 likes
    Last Post tkaboris  
    Working...
    X