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

dynamic enum?

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

    dynamic enum?

    I am familiar with the examples in this forum using a static (hard coded) enum that allow the user to select a predefined value from a drop-down list. I would like to populate this drop-down list with the list of files from a specified path. Since enums are hard coded-I'd like to essentially create a dynamic enum (although this may not be a true enum 'structure')...because the list of files is in fact dynamic as a new one is added once/day.

    This may not be a supported topic--so I am hoping there might be someone out there that might know how to do this and be so kind to answer this...

    I know how to get the list of the files, I have the variable (one of the indicator's parameters) for the user to specify the date they want to use (which corresponds to a file in this directory)--which they now have to type in manually in the "Parameters" section. If they specify a valid date, the correct file's data is read, etc. so everything else is working now.

    But I do not know how to change this from a manual entry to one in which the existing list of data-files are listed in a drop-down list so the user can select from them.

    I understand / assume I'd have to live with the limitation that the list of files in the directory would only contain the files that were there when the ninjascript was initially loaded--so the user would have to reload the ninjascript indicator once/day---since a new file is added once/day. But this isn't a showstopper if it is in fact a limitation.
    Jim-Boulder
    NinjaTrader Ecosystem Vendor - Elephant Tracks

    #2
    It sounds like a "File selection dialog box" would make a better choice, Have you looked into that ?
    Last edited by koganam; 11-13-2012, 04:42 PM. Reason: Corrected spelling.

    Comment


      #3
      Jim-Boulder, you are correct, this would be more of a general C# topic instead of NinjaScript specific, so it is unsupported.
      AustinNinjaTrader Customer Service

      Comment


        #4
        Koganam,

        Thanks for the idea. I'll look into that--the desired effect is that on the Indicator "parameters" screen-the user would click on the file name parameter and a drop-down list would appear---I wasn't sure how to enable a file selection dialogue box to work on the 'parameters' screen....

        Do you know if there's anything special I have to do to enable a drop-down in one of the indicator's parameter's field?
        Jim-Boulder
        NinjaTrader Ecosystem Vendor - Elephant Tracks

        Comment


          #5
          Originally posted by Jim-Boulder View Post
          Koganam,

          Thanks for the idea. I'll look into that--the desired effect is that on the Indicator "parameters" screen-the user would click on the file name parameter and a drop-down list would appear---I wasn't sure how to enable a file selection dialogue box to work on the 'parameters' screen....

          Do you know if there's anything special I have to do to enable a drop-down in one of the indicator's parameter's field?
          You are going to need an EditorAttribute in your properties specification. Try this:

          Code:
          [EditorAttribute(typeof(System.Windows.Forms.Design.FileNameEditor), typeof(System.Drawing.Design.UITypeEditor))]
          public string testFilename
          {
              get
              {
                  return filename;
              }
              set
              {
                  filename = value;
              }
          }
          private string filename;
          Let us know how you get along.

          Comment


            #6
            SO I tried this and got it to compile but it did not result in a drop-down menu list on the parameters screen--just a blank field .

            Here's the code I had previously used to verify that I can get the list of file names that are in the Ninja Trader folder under My Doc's and pulls files that start with "TP":

            string[] filePaths = Directory.GetFiles(@Cbi.Core.UserDataDir.ToString( ),"TP-*",SearchOption.TopDirectoryOnly);
            for (int i = 0; i < filePaths.Length; ++i)
            {
            string path2 = filePaths[i];
            Print(System.IO.Path.GetFileName(path2));
            }



            -------------------------

            I don't know how to change the code you shared to refer to this list of files....

            ----------Jim
            Jim-Boulder
            NinjaTrader Ecosystem Vendor - Elephant Tracks

            Comment


              #7
              Originally posted by Jim-Boulder View Post
              SO I tried this and got it to compile but it did not result in a drop-down menu list on the parameters screen--just a blank field .

              Here's the code I had previously used to verify that I can get the list of file names that are in the Ninja Trader folder under My Doc's and pulls files that start with "TP":

              string[] filePaths = Directory.GetFiles(@Cbi.Core.UserDataDir.ToString( ),"TP-*",SearchOption.TopDirectoryOnly);
              for (int i = 0; i < filePaths.Length; ++i)
              {
              string path2 = filePaths[i];
              Print(System.IO.Path.GetFileName(path2));
              }



              -------------------------

              I don't know how to change the code you shared to refer to this list of files....

              ----------Jim
              Click on the blank field and it should produce an ellipsis in a button. Click on that and it should open a File Selection Dialog Box.

              So, at first it looks like in FileSelectionDialog1.png. After you click on the field, it should look like FileSelectionDialog2. Until you click in the field, you are not modifying it, so it simply displays what is in the field.
              Attached Files
              Last edited by koganam; 06-28-2011, 10:55 AM.

              Comment


                #8
                thanks again---could you attach your code?--I still can't get the ellipsis in the button--and I'd like to see your whole set of code-because I must have something overriding it in my code

                thanks....
                Jim-Boulder
                NinjaTrader Ecosystem Vendor - Elephant Tracks

                Comment


                  #9
                  Originally posted by Jim-Boulder View Post
                  thanks again---could you attach your code?--I still can't get the ellipsis in the button--and I'd like to see your whole set of code-because I must have something overriding it in my code

                  thanks....
                  Attached per your request. The code is exactly what I posted, so I do not see how it can make a difference.
                  Attached Files

                  Comment


                    #10
                    thanks--I just wanted to be using the exact same code as you to eliminate all variability--anyway--I used your code and still don't get the elipse--but in checking--my reference to system.design.dll is not from .Net2 or even .net4 --it is pointing to .netframework --so this may be the problem--I am using .net 4 but there is no system.design.dll under that folder....so this is probably the issue...

                    thanks for sharing the code---that was helpful.

                    I'll have to research how to get this system.design.dll properly.
                    Jim-Boulder
                    NinjaTrader Ecosystem Vendor - Elephant Tracks

                    Comment


                      #11
                      Originally posted by Jim-Boulder View Post
                      thanks--I just wanted to be using the exact same code as you to eliminate all variability--anyway--I used your code and still don't get the elipse--but in checking--my reference to system.design.dll is not from .Net2 or even .net4 --it is pointing to .netframework --so this may be the problem--I am using .net 4 but there is no system.design.dll under that folder....so this is probably the issue...

                      thanks for sharing the code---that was helpful.

                      I'll have to research how to get this system.design.dll properly.
                      You definitely need to have .NET 2 installed, and reference that dll. Zeos6 had pretty much the same problem until he did as I suggested.

                      ref: http://www.ninjatrader.com/support/f...ad.php?t=42166

                      You can see here where I have deliberately loaded the one from ver2.0.50727
                      Attached Files
                      Last edited by koganam; 06-28-2011, 12:34 PM.

                      Comment


                        #12
                        For ninjatrader 7:
                        seems you can get that old dll from here: https://www.dll4free.com/system.design.dll.html (but choose version 1.xxxx), or just without need of any dll, you can use custom namespace:

                        Code:
                        [EditorAttribute(typeof(myNs.FileNameEditor), typeof(System.Drawing.Design.UITypeEditor))]
                        and include this code: https://pastebin.com/raw/mih2Ny2V


                        For NT8, just this:

                        [PropertyEditor("NinjaTrader.Gui.Tools.FilePathPick er", Filter = "Wav Files (*.wav)|*.wav")]
                        Last edited by ttodua; 07-10-2019, 05:05 AM.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by Javierw.ok, Today, 04:12 PM
                        0 responses
                        4 views
                        0 likes
                        Last Post Javierw.ok  
                        Started by timmbbo, Today, 08:59 AM
                        2 responses
                        10 views
                        0 likes
                        Last Post bltdavid  
                        Started by alifarahani, Today, 09:40 AM
                        6 responses
                        40 views
                        0 likes
                        Last Post alifarahani  
                        Started by Waxavi, Today, 02:10 AM
                        1 response
                        18 views
                        0 likes
                        Last Post NinjaTrader_LuisH  
                        Started by Kaledus, Today, 01:29 PM
                        5 responses
                        15 views
                        0 likes
                        Last Post NinjaTrader_Jesse  
                        Working...
                        X