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 PaulMohn, Today, 03:49 AM
              0 responses
              6 views
              0 likes
              Last Post PaulMohn  
              Started by inanazsocial, Today, 01:15 AM
              1 response
              9 views
              0 likes
              Last Post NinjaTrader_Jason  
              Started by rocketman7, Today, 02:12 AM
              0 responses
              10 views
              0 likes
              Last Post rocketman7  
              Started by dustydbayer, Today, 01:59 AM
              0 responses
              4 views
              0 likes
              Last Post dustydbayer  
              Started by trilliantrader, 04-18-2024, 08:16 AM
              5 responses
              23 views
              0 likes
              Last Post trilliantrader  
              Working...
              X