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

List of doubles/floats in parameter menu

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

    List of doubles/floats in parameter menu

    Hello,

    I would like to add a drop-down list of double values from which a user can select. Ordinarily, I would simply create an enum, but cannot do this with double data types.

    Is there any way to have a "list" of doubles appear in the parameter menu? I am probably overlooking a simple solution to this problem.

    Thank you.

    #2
    Hello ivb73077,

    Thank you for your post.

    Define the cases in the enum as strings:
    Code:
    public enum MyDouble
    {
    	One,
    	Two,
    	Three,
    	Four,
    	// etc.
    }
    Then when you call the actual cases in the switch, assign the actual value:
    Code:
            #region Variables
            private MyDouble myDbl = MyDouble.One;
    		private double result = 0;
            #endregion
    ...
    Code:
            protected override void OnBarUpdate()
            {
    			switch (myDbl)
    			{
    				case MyDouble.One:
    				{
    					result = 1;
    					break;
    				}
    				case MyDouble.Two:
    				{
    					result = 2;
    					break;
    				}
    				case MyDouble.Three:
    				{
    					result = 3;
    					break;
    				}
    				case MyDouble.Four:
    				{
    					result = 4;
    					break;
    				}
    			}
            }

    Comment


      #3
      Patrick,

      This is a completely viable solution that I can readily implement. Thank you.

      For my own understanding, is there a way to have the actual list/array of doubles appear in the parameter list? I had tried creating an array of doubles, but the field gets populated with "double[] arrayName" which, when expanded, reveals the elements of the array.

      Comment


        #4
        Hello ivb73077,

        I do not believe that is possible, but I could be wrong on this.

        Comment


          #5
          Fair enough. Thank you for the solution you proposed earlier. It is sufficient for my needs.

          Comment


            #6
            Originally posted by ivb73077 View Post
            Patrick,

            This is a completely viable solution that I can readily implement. Thank you.

            For my own understanding, is there a way to have the actual list/array of doubles appear in the parameter list? I had tried creating an array of doubles, but the field gets populated with "double[] arrayName" which, when expanded, reveals the elements of the array.
            To do that you would create a listbox control.

            Comment


              #7
              Another good option. Thanks.

              Comment

              Latest Posts

              Collapse

              Topics Statistics Last Post
              Started by Segwin, 05-07-2018, 02:15 PM
              14 responses
              1,788 views
              0 likes
              Last Post aligator  
              Started by Jimmyk, 01-26-2018, 05:19 AM
              6 responses
              837 views
              0 likes
              Last Post emuns
              by emuns
               
              Started by jxs_xrj, 01-12-2020, 09:49 AM
              6 responses
              3,293 views
              1 like
              Last Post jgualdronc  
              Started by Touch-Ups, Today, 10:36 AM
              0 responses
              13 views
              0 likes
              Last Post Touch-Ups  
              Started by geddyisodin, 04-25-2024, 05:20 AM
              11 responses
              63 views
              0 likes
              Last Post halgo_boulder  
              Working...
              X