• If this is your first visit, you will have to register before you can post. To view messages, please scroll below and select the forum that you would like to visits. Questions? Be sure to check out the Forum FAQ.

Announcement

Collapse
No announcement yet.

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;
    				}
    			}
            }
    Patrick H.NinjaTrader Customer Service

    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.
        Patrick H.NinjaTrader Customer Service

        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 Jurase, Today, 06:47 PM
              2 responses
              5 views
              0 likes
              Last Post Jurase
              by Jurase
               
              Started by GTBrooks, Today, 05:53 PM
              0 responses
              2 views
              0 likes
              Last Post GTBrooks  
              Started by jeronymite, Today, 04:50 PM
              0 responses
              5 views
              0 likes
              Last Post jeronymite  
              Started by daigo1, Today, 04:41 PM
              0 responses
              14 views
              0 likes
              Last Post daigo1
              by daigo1
               
              Started by Harrylwd4, Today, 03:15 PM
              1 response
              11 views
              0 likes
              Last Post NinjaTrader_ChrisL  
              Working...
              X