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

Instrument Selector as an input parameter

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

    Instrument Selector as an input parameter

    Hello

    How can I code an Istrument Selector as an input paramtere in an indicator? I need something like a combobox which will display a list of Instrument names. I can do that by creating an Enum with Instrument names, then parse the names, but that is a static solution, and it has to be done before compile-time. I need it to display a list of currently available instruments in the system dynamically.

    Thank you
    J

    #2
    Hello J,

    Thank you for your post.

    Using an enum list would be the supported method to do this. Accessing the database for the instruments currently listed is not supported in NinjaScript. However, there may be unsupported code on how to do this, I am unfortunately unaware of such code.

    Comment


      #3
      Hi Patrick.

      Thank you for your reply.

      Let me then ask another question: is there a way to display a list of strings for the user to choose from, in a form of a combobox, just like Enum does? But, the list will be created at *run-time*, and not at compile-time (like a static Enum).

      i know i can just let the user type the instrument name in a box. Tha is not the requirement though. Tha requirement is a list of strings.

      Thank you for your help.

      Jaba

      Comment


        #4
        Hello J,

        Thank you for your response.

        You could use OnStartUp() to run any items only on start up of the code and the List Class to create a list of strings.

        For information on OnStartUp() please visit the following link: http://www.ninjatrader.com/support/h.../onstartup.htm

        For information on the List Class please visit the following link: http://msdn.microsoft.com/en-us/library/6sh2ey19.aspx

        Please let me know if I may be of further assistance.

        Comment


          #5
          Patrick

          Thanks a lot for your help, especially on Sunday

          I am trying to code what you suggested. Here's what I got so far:

          Code:
          [COLOR=blue]public[/COLOR] [COLOR=#2b91af]List[/COLOR]<[COLOR=blue]string[/COLOR]> MYLIST
          {
                      [COLOR=blue]get[/COLOR] { [COLOR=blue]return[/COLOR] masterList;}
                      [COLOR=blue]set[/COLOR] { masterList = [COLOR=blue]value[/COLOR]; }
          }
          Global Var:
          [COLOR=blue]private[/COLOR] [COLOR=#2b91af]List[/COLOR]<[COLOR=blue]string[/COLOR]> masterList = [COLOR=blue]new[/COLOR] [COLOR=#2b91af]List[/COLOR]<[COLOR=blue]string[/COLOR]>();
           
           in OnStartUp() to populate the list with something:
                      [COLOR=blue]for[/COLOR] ([COLOR=blue]int[/COLOR] iii = 0; iii < 10; iii++)
                      {
                          masterList.Add([COLOR=#a31515]"elem_"[/COLOR] + iii);
                      }
          When I click on the MYLIST param, another form with two panes opens, which has some "collection" title. How do I return the selected item from this? I really would like the drop-down, comboBox-like interface. Can this be done?
          Thanks again
          J

          Comment


            #6
            Hello J,

            Thank you for your response.

            The enum is the the only supported method for the drop down menu.

            Comment


              #7
              I just want to make sure that I understand what you are saying.

              So, what you are saying means that there is no way to create a dynamic list of choices in the indicator properties, and let the end-user pick one. Am I correct?

              Best regards
              J

              Comment


                #8
                Please disregard my previous post. It could be done, as you can see in the screenshot attached.

                It was harder than I expected, but it is not NinjaTrader's fault. It just took some digging around

                Thanks for your help I learned a lot today.
                J


                ==========
                Attached Files

                Comment


                  #9
                  Originally posted by Jaba1n View Post
                  Please disregard my previous post. It could be done, as you can see in the screenshot attached.

                  It was harder than I expected, but it is not NinjaTrader's fault. It just took some digging around

                  Thanks for your help I learned a lot today.
                  J


                  ==========
                  Nice. It looks like you managed to get the PropertyGrid to handle a ComboBox. Do you know how to make the PropertyGrid handle a LinkLabel?

                  Comment


                    #10
                    Hey, koganam, long time no see

                    I would have to extend UITypeEditor to do that.

                    I'm sure you've walked that path many times

                    J
                    Last edited by Jaba1n; 04-21-2013, 10:16 PM.

                    Comment


                      #11
                      Originally posted by Jaba1n View Post
                      Hey, koganam, long time no see

                      I would have to extend UITypeEditor to do that.

                      I'm sure you've walked that path many times

                      J
                      Aargh!! Exactly what I was hoping that I would NOT have to do. Bummer.

                      I trust that all is well with you?

                      Thanks.

                      Comment


                        #12
                        Yes, all is good, thanks for asking. Let me know if you need any help with the linklabel. Cheers.
                        J

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by mjairg, 07-20-2023, 11:57 PM
                        3 responses
                        213 views
                        1 like
                        Last Post PaulMohn  
                        Started by TheWhiteDragon, 01-21-2019, 12:44 PM
                        4 responses
                        544 views
                        0 likes
                        Last Post PaulMohn  
                        Started by GLFX005, Today, 03:23 AM
                        0 responses
                        3 views
                        0 likes
                        Last Post GLFX005
                        by GLFX005
                         
                        Started by XXtrader, Yesterday, 11:30 PM
                        2 responses
                        12 views
                        0 likes
                        Last Post XXtrader  
                        Started by Waxavi, Today, 02:10 AM
                        0 responses
                        7 views
                        0 likes
                        Last Post Waxavi
                        by Waxavi
                         
                        Working...
                        X