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

How to setup enum so property displays actual numbers?

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

    How to setup enum so property displays actual numbers?

    How to I format an enum so that used in a user selectable property, will display in the dropdown the actual numbers the way the Panel property does. Like this:
    1
    2
    3

    The following attempts do not compile:
    Code:
    enum SelectNumber
    {
      1,
      2,
      3
    }
    
    enum SelectNumber
    {
      "1",
      "2",
      "3"
    }
    
    enum SelectNumber
    {
      '1',
      '2',
      '3'
    }

    #2
    shawnj,

    Unfortunately this is outside the scope of what we can support. I suggest you try going to MSDN or google C# enum. Thank you for understanding.
    Josh P.NinjaTrader Customer Service

    Comment


      #3
      I have searched. I was hoping someone could explain how NT displays the dropdown of numbers in the Panel property of an indicator. I assume there is an enum named Panel in the code. I also assume there is some formatting trick to get the compiler to accept integer numbers. Just asking.

      Comment


        #4
        shawnj,

        Unfortunately we cannot assist as this is advanced C# that we just can't cover here on the forums. If someone else wants to chime in feel free to though. Thank you for understanding.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          Originally posted by NinjaTrader_Josh View Post
          shawnj,

          Unfortunately we cannot assist as this is advanced C# that we just can't cover here on the forums. If someone else wants to chime in feel free to though. Thank you for understanding.
          Never mind...
          Last edited by roonius; 01-08-2009, 08:36 PM.

          Comment


            #6
            ... Unfortunately ... this thread has absolutely nothing to do with NT, roonius. It is indeed advanced C# programming.

            shawnj,

            you try to use an enum for something it is not intended for. To get a drop down list in the property grid you could write an own typeconverter. Therefor you need to understand the concept of a typeconverter. How to design one is described here (including an example):



            Regards
            Ralph

            Comment


              #7
              Help

              roonius I totally agree with you. If you come from tradestation this is a nightmare in terms of help - its just not friendly.

              try here


              if you download the code there is a fully funcitioning enum module inside it.

              Comment


                #8
                The NT Support Group is supporting the "Intended Use" of NT and doing a wonderful job of it. They are not running a C# Programming School. The good news about NT is if you can think it up it can be coded. Bad news is that you have to code it yourself requiring you to have some knowledge of C#. The good news is there are lots of books on C# Programming at your local book store to aid your development process. I would encourage anyone that wants to write their own indicators/strategies to invest in a few of them. 50% of what I do is outside the box of what NT supports.

                Thanks NT for not being TS or ES or MT!

                Comment


                  #9
                  Thank you all for voicing your opinions. We cover some more advanced subjects in our reference sample section of the forum - http://www.ninjatrader-support2.com/...splay.php?f=30

                  There is also one for the enums - http://www.ninjatrader-support2.com/...ead.php?t=3420

                  I can understand it may be frustrating for some, but this is the tradeoff to have access to a much more powerful coding language like C#.

                  Thank you for your understanding and may all your codes compile!
                  BertrandNinjaTrader Customer Service

                  Comment


                    #10
                    Hi Bertrand,

                    if I understand NT's enum sample correctly, it demonstrates that the user could use the enum with the property grid to select from. It is just working as coded because there is an implicit type converter implemented in C#.

                    But what to do, if you would like to select from a collection of integers? You couldn't put this into an enum because it is rejected by the compiler.

                    One way of implementing is to derive a sub-class from the typeconverter class. Perhaps there are other solutions, I just know of this single one. (I provided the link to a MSDN code example in a previous reply.)

                    And yes, may all code compile.

                    Regards
                    Ralph

                    Comment


                      #11
                      To Ralph (and TAJTrades):
                      This is a "General Programming - General NinjaScript programming questions" forum. All ninjascript code is written in C#. How can we not talk about C# here? I've read over a dozen C# and .net programming books and countless books on other programming languages and have not come across what I'm asking about here.

                      I think what I'm asking here is very relevant to NT. Being able to select an integer from a dropdown when setting up an indicator on a chart is a very useful thing. Plus there is a working example with the Panel property.

                      But Ralph thanks for the link. I was hoping there was some little formatting trick that I was not aware of that could be applied to an enum that would do what I was looking for. It looks like the typeconverter route will get me there but wow.

                      To Midset:
                      Thanks for the example.

                      To All:
                      Just to clarify, I'm not asking either how to write an enum or how to use an enum in a property that will create a dropdown the user can select from in the property panel. I know how to do that. I'm asking how to get the dropdown to display integers the way the Panel property does.

                      Right now I'm using the following which works but is crude:

                      Code:
                      enum SelectNumber
                      {
                        one,
                        two,
                        three
                      }
                      And what Mindset is saying, I believe, is that in the Tradestation forums, 95+ percent of the message traffic is NOT from Tradestation personnel. But that is probably more a function of the ratio of Tradestation users (and coders) to NT users (and coders). I'm guessing 50 to 1. Hopefully the friendliness of this forum will improve as more Tradestation users and coders "see the light" as I have.

                      And To roonius:
                      I don't know this but I'm guessing the NT support personel have some sort of metric where they are "graded" by either how quickly a response is given or by how few messages go unanswered. No offense to Josh or any of the other NT support folk is intended here.
                      Last edited by shawnj; 12-19-2008, 05:19 AM.

                      Comment


                        #12
                        shawnj,

                        There is no metric. What we support is anything available in the Help Guide. Occasionally we will go a little bit more, but we have to draw the line somewhere. The official line is if its not in the Help Guide we just do not have enough bandwidth to offer support. This by no means implies that community members can't jump in and try to figure it out. It just means we, as the support staff, cannot assist much in the endeavor.
                        Josh P.NinjaTrader Customer Service

                        Comment


                          #13
                          Forum members

                          Yes - its down to the members to assist others. This forum will ultimately flourish if users help other users.
                          We have all had to learn something new and a little help can go a long way.
                          NT support can only go so far - I just don't feel it goes quite far enough!

                          Ok lets draw a line here and get on with it.

                          Comment


                            #14
                            Code example

                            Nice to see we are back in harmony.

                            Shawn, attached you find a code example how to use a drop down list for integer values with the property grid, implemented as an indicator. With such kind of a sub-class for the typeconverter you could display any kind of information you like to (i.e. the content of a filesystem directory or even the content of an object). You just need to code it .

                            With the current code setup you are able to modify the selected value. If you want to fix it, you need to set the return value of GetStandardValuesExclusive() to true. Your integer collection is defined with GetStandardValues(). Don't forget to set a '
                            using System.Globalization', some methods use CultureInfo as parameter. I attached a little picture of the property grid in operation.

                            For all who didn't notice: This efford is not required if you would like to display the content of an enumeration.

                            Regards
                            Ralph
                            Attached Files

                            Comment


                              #15
                              Ralph, fantastic work. You are a scholar and a gentleman. I hope I can repay you and the group some time in the future.

                              thanks,
                              shawnj

                              Comment

                              Latest Posts

                              Collapse

                              Topics Statistics Last Post
                              Started by judysamnt7, 03-13-2023, 09:11 AM
                              4 responses
                              59 views
                              0 likes
                              Last Post DynamicTest  
                              Started by ScottWalsh, Today, 06:52 PM
                              4 responses
                              36 views
                              0 likes
                              Last Post ScottWalsh  
                              Started by olisav57, Today, 07:39 PM
                              0 responses
                              7 views
                              0 likes
                              Last Post olisav57  
                              Started by trilliantrader, Today, 03:01 PM
                              2 responses
                              21 views
                              0 likes
                              Last Post helpwanted  
                              Started by cre8able, Today, 07:24 PM
                              0 responses
                              10 views
                              0 likes
                              Last Post cre8able  
                              Working...
                              X