Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Sorting in Ninja script

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

    #46
    Thanks for clearing the mistake.
    Now I'll try to finish the work.

    Comment


      #47
      One small thing:
      when sorting values or strings, the routine places "9" before "80", considering the alphabetical order instead of the numerical one.
      How may I get a mathematical arrangement (or otherwise change "9" to "09") ?

      Comment


        #48
        Originally posted by Mauripasto View Post
        One small thing:
        when sorting values or strings, the routine places "9" before "80", considering the alphabetical order instead of the numerical one.
        How may I get a mathematical arrangement (or otherwise change "9" to "09") ?
        Are you sure that you wrote what you intended? "9" does come before "80" in canonical order, so the request is a little difficult to understand.

        If you want "09" instead of "9", why not put that directly when you add it to the list?

        Comment


          #49
          Correct, canonically 9 comes before 80, but since I'm dealing with values, 80 is mathematically greater than 9 and should be considered this way and displayed above / before 9.
          Always for the same reason, my algorythm returns me numbers, i.e. a "9", not a "09". Of course, the script could place the "0" before 9 on my behalf, but here I would face some other limitation, therefore I'd prefer the former (mathematical) solution.

          Comment


            #50
            Originally posted by Mauripasto View Post
            Correct, canonically 9 comes before 80, but since I'm dealing with values, 80 is mathematically greater than 9 and should be considered this way and displayed above / before 9.
            Always for the same reason, my algorythm returns me numbers, i.e. a "9", not a "09". Of course, the script could place the "0" before 9 on my behalf, but here I would face some other limitation, therefore I'd prefer the former (mathematical) solution.
            So is your list a list of numbers or a list of strings?

            Comment


              #51
              It's a string. Beginning with a number from 0 to 100 (the sorting key).

              Comment


                #52
                Originally posted by Mauripasto View Post
                It's a string. Beginning with a number from 0 to 100 (the sorting key).
                Then this statement is ununderstandable.
                Always for the same reason, my algorythm returns me numbers, i.e. a "9", not a "09". Of course, the script could place the "0" before 9 on my behalf, but here I would face some other limitation, therefore I'd prefer the former (mathematical) solution.
                Numbers are not strings. If your list is made up of strings, you cannot say that it returns numbers, unless you are parsing the strings to return numbers. If that is what you are doing, then, while I understand your want and need for secrecy, there is really just not enough information on what you are doing, for me to really help.

                You will have to disclose a lot more about what you are doing for this conversation to remain meaningful. We cannot be processing strings, and suddenly be talking about numbers. At the very least, you have to say what data you are processing; the type and example of your input data; the type and example of your output data; what you are expecting, and not getting. These cryptic snippets are just not a workable proposition.

                I really do not want to see the entire code: that should be yours to disclose, only at your own comfort level. If it is necessary to disclose the entire code, and you still need your secret sauce to remain secret, I would have to bow out, so that you deal directly with NinjaTrader, rather than a stranger.
                Last edited by koganam; 06-24-2015, 05:06 PM.

                Comment


                  #53
                  There is absolutely no secrecy, I could send you the whole code with no problem, but we would only make things much more complicated and ununderstandable.
                  We already discussed this a month ago: in only one string for each symbol, I keep all information I need (the instrument name, its actual and past trend, an index of its strenght, the values of different indicators, ...). I often find useful for my trading to compare, arrange and list my preferred equities on the basis of either one of those indicators (for istance, let's say the actual ADX): all I do is simply to retrieve its value from the string and to put it at the beginning of the string, and so I get my list of symbols sorted as wished according to.their ADX. That's all. It may well be an inelegant programming method, but it's simple and it works fine, I can assure. The small mentioned problem was that values under 10 are listed before the 2-digit ones, but in the meanwhile I found a solution: I simply remove the few strings with key values under 10, which would be anyway at the bottom of the arrangement, i.e. presently irrelevant for my trading. A further inelegant measure, but once again, plain and effective.
                  I thank you anyway for all your good programming advice I could profit of in this thread.
                  Last edited by Mauripasto; 06-24-2015, 12:47 PM.

                  Comment


                    #54
                    Originally posted by Mauripasto View Post
                    There is absolutely no secrecy, I could send you the whole code with no problem, but we would only make things much more complicated and ununderstandable.
                    We already discussed this a month ago: in only one string for each symbol, I keep all information I need (the instrument name, its actual and past trend, an index of its strenght, the values of different indicators, ...). I often find useful for my trading to compare, arrange and list my preferred equities on the basis of either one of those indicators (for istance, let's say the actual ADX): all I do is simply to retrieve its value from the string and to put it at the beginning of the string, and so I get my list of symbols sorted as wished according to.their ADX. That's all. It may well be an inelegant programming method, but it's simple and it works fine, I can assure. The small mentioned problem was that values under 10 are listed before the 2-digit ones, but in the meanwhile I found a solution: I simply remove the few strings with key values under 10, which would be anyway at the bottom of the arrangement, i.e. presently irrelevant for my trading. A further inelegant measure, but once again, plain and effective.
                    I thank you anyway for all your good programming advice I could profit of in this thread.
                    Nothing inelegant about what you describe. You crunch the numbers as you see fit.

                    But let us assume that you have a string that we shall call ADXResultString, to hold your entire string, and ADX returns a value less than 10. This is how you would concatenate the string.
                    Code:
                    if (ADX(Period)[0] < 10) ADXResultString = "0" + ADX(Period)[0].ToString() /* + other concatenation strings required here */; 
                    else ADXResultString = ADX(Period)[0].ToString() /* + other concatenation strings required here */;
                    You can then put that string in the list.

                    You may want to custom format your string or Round2TickSize(), as ADX() returns a double, with what is often, a pretty long decimal part.

                    Comment


                      #55
                      Originally posted by Mauripasto View Post
                      The small mentioned problem was that values under 10 are listed before the 2-digit ones, but in the meanwhile I found a solution: I simply remove the few strings with key values under 10, which would be anyway at the bottom of the arrangement, i.e. presently irrelevant for my trading. A further inelegant measure, but once again, plain and effective.
                      Padding the strings with 0 would solve your issue in sorting strings that contain numbers.

                      001
                      002
                      010
                      100

                      would sort properly.

                      Comment


                        #56
                        Thank you both, I'll work on this.

                        Comment

                        Latest Posts

                        Collapse

                        Topics Statistics Last Post
                        Started by ageeholdings, Today, 07:43 AM
                        0 responses
                        7 views
                        0 likes
                        Last Post ageeholdings  
                        Started by pibrew, Today, 06:37 AM
                        0 responses
                        4 views
                        0 likes
                        Last Post pibrew
                        by pibrew
                         
                        Started by rbeckmann05, Yesterday, 06:48 PM
                        1 response
                        14 views
                        0 likes
                        Last Post bltdavid  
                        Started by llanqui, Today, 03:53 AM
                        0 responses
                        6 views
                        0 likes
                        Last Post llanqui
                        by llanqui
                         
                        Started by burtoninlondon, Today, 12:38 AM
                        0 responses
                        12 views
                        0 likes
                        Last Post burtoninlondon  
                        Working...
                        X