Announcement

Collapse
No announcement yet.

Partner 728x90

Collapse

Sorting values in a DataSeries

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

    Sorting values in a DataSeries

    I am calculating a value for each bar stored in a DataSeries object.
    I want to be able to sort the last 210 values and find the 20th highest and 20th lowest values.

    I know I can assign it to an array and then sort the array. Is there a more straight forward way to sort set of number in a DataSeries object?

    #2
    Hello afshinmoshrefi,

    There would not be a simpler method to be able to accomplish finding the 20th Highest/Lowest values other than the one that you stated that I can think of.
    JCNinjaTrader Customer Service

    Comment


      #3
      Originally posted by afshinmoshrefi View Post
      I am calculating a value for each bar stored in a DataSeries object.
      I want to be able to sort the last 210 values and find the 20th highest and 20th lowest values.

      I know I can assign it to an array and then sort the array. Is there a more straight forward way to sort set of number in a DataSeries object?
      This is the way that I have done it to code a median with percentile bands. However, I have used a dynamic array (private List<double>) in order not to limit the number of fields.

      An important consideration is not to do the sorting with each incoming tick. I would therefore sort the 209 values with the first tick of each bar, store this array and then insert the new value for the current bar in a second step, before retrieving the percentile values. Of course, this two step process is only necessary, if you wish to use the indicator with COBC = false.

      Comment

      Latest Posts

      Collapse

      Topics Statistics Last Post
      Started by Geovanny Suaza, 02-11-2026, 06:32 PM
      0 responses
      601 views
      0 likes
      Last Post Geovanny Suaza  
      Started by Geovanny Suaza, 02-11-2026, 05:51 PM
      0 responses
      347 views
      1 like
      Last Post Geovanny Suaza  
      Started by Mindset, 02-09-2026, 11:44 AM
      0 responses
      103 views
      0 likes
      Last Post Mindset
      by Mindset
       
      Started by Geovanny Suaza, 02-02-2026, 12:30 PM
      0 responses
      559 views
      1 like
      Last Post Geovanny Suaza  
      Started by RFrosty, 01-28-2026, 06:49 PM
      0 responses
      558 views
      1 like
      Last Post RFrosty
      by RFrosty
       
      Working...
      X