Now I'll try to finish the work.
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Sorting in Ninja script
Collapse
X
-
-
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
-
Originally posted by Mauripasto View PostOne 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") ?
If you want "09" instead of "9", why not put that directly when you add it to the list?
Comment
-
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
-
Originally posted by Mauripasto View PostCorrect, 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
-
-
Originally posted by Mauripasto View PostIt's a string. Beginning with a number from 0 to 100 (the sorting key).
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.
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
-
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
-
Originally posted by Mauripasto View PostThere 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.
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 may want to custom format your string or Round2TickSize(), as ADX() returns a double, with what is often, a pretty long decimal part.
Comment
-
Originally posted by Mauripasto View PostThe 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.
001
002
010
100
would sort properly.
Comment
-
Latest Posts
Collapse
Topics | Statistics | Last Post | ||
---|---|---|---|---|
Started by ageeholdings, Today, 07:43 AM
|
0 responses
7 views
0 likes
|
Last Post
by ageeholdings
Today, 07:43 AM
|
||
Started by pibrew, Today, 06:37 AM
|
0 responses
4 views
0 likes
|
Last Post
by pibrew
Today, 06:37 AM
|
||
Started by rbeckmann05, Yesterday, 06:48 PM
|
1 response
14 views
0 likes
|
Last Post
by bltdavid
Today, 05:43 AM
|
||
Started by llanqui, Today, 03:53 AM
|
0 responses
6 views
0 likes
|
Last Post
by llanqui
Today, 03:53 AM
|
||
Started by burtoninlondon, Today, 12:38 AM
|
0 responses
12 views
0 likes
|
Last Post Today, 12:38 AM |
Comment