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 itrader46, Today, 09:04 AM
              0 responses
              3 views
              0 likes
              Last Post itrader46  
              Started by timmbbo, Today, 08:59 AM
              0 responses
              1 view
              0 likes
              Last Post timmbbo
              by timmbbo
               
              Started by bmartz, 03-12-2024, 06:12 AM
              5 responses
              33 views
              0 likes
              Last Post NinjaTrader_Zachary  
              Started by Aviram Y, Today, 05:29 AM
              4 responses
              14 views
              0 likes
              Last Post Aviram Y  
              Started by algospoke, 04-17-2024, 06:40 PM
              3 responses
              28 views
              0 likes
              Last Post NinjaTrader_Jesse  
              Working...
              X