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 SalmaTrader, 07-07-2026, 10:26 PM
      0 responses
      29 views
      0 likes
      Last Post SalmaTrader  
      Started by CarlTrading, 07-05-2026, 01:16 PM
      0 responses
      17 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 06-17-2026, 10:32 AM
      0 responses
      9 views
      0 likes
      Last Post CaptainJack  
      Started by kinfxhk, 06-17-2026, 04:15 AM
      0 responses
      15 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Started by kinfxhk, 06-17-2026, 04:06 AM
      0 responses
      18 views
      0 likes
      Last Post kinfxhk
      by kinfxhk
       
      Working...
      X