• 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 bchip, Today, 09:25 AM
              1 response
              9 views
              0 likes
              Last Post NinjaTrader_ChelseaB  
              Started by Tomass, Today, 09:25 AM
              2 responses
              11 views
              0 likes
              Last Post Tomass
              by Tomass
               
              Started by hundert, Today, 08:37 AM
              3 responses
              17 views
              0 likes
              Last Post NinjaTrader_Melissa  
              Started by ronaldgreene828, Today, 08:16 AM
              1 response
              7 views
              0 likes
              Last Post NinjaTrader_PatrickG  
              Started by hir04068, Today, 01:36 AM
              1 response
              18 views
              0 likes
              Last Post NinjaTrader_PaulH  
              Working...
              X