Announcement

Collapse

Looking for a User App or Add-On built by the NinjaTrader community?

Visit NinjaTrader EcoSystem and our free User App Share!

Have a question for the NinjaScript developer community? Open a new thread in our NinjaScript File Sharing Discussion Forum!
See more
See less

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 ageeholdings, Today, 07:43 AM
      0 responses
      5 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