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 CarlTrading, 03-31-2026, 09:41 PM
      1 response
      82 views
      1 like
      Last Post NinjaTrader_ChelseaB  
      Started by CarlTrading, 04-01-2026, 02:41 AM
      0 responses
      43 views
      0 likes
      Last Post CarlTrading  
      Started by CaptainJack, 03-31-2026, 11:44 PM
      0 responses
      64 views
      2 likes
      Last Post CaptainJack  
      Started by CarlTrading, 03-30-2026, 11:51 AM
      0 responses
      68 views
      0 likes
      Last Post CarlTrading  
      Started by CarlTrading, 03-30-2026, 11:48 AM
      0 responses
      56 views
      0 likes
      Last Post CarlTrading  
      Working...
      X