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 PaulMohn, Today, 03:49 AM
      0 responses
      4 views
      0 likes
      Last Post PaulMohn  
      Started by inanazsocial, Today, 01:15 AM
      1 response
      7 views
      0 likes
      Last Post NinjaTrader_Jason  
      Started by rocketman7, Today, 02:12 AM
      0 responses
      10 views
      0 likes
      Last Post rocketman7  
      Started by dustydbayer, Today, 01:59 AM
      0 responses
      2 views
      0 likes
      Last Post dustydbayer  
      Started by trilliantrader, 04-18-2024, 08:16 AM
      5 responses
      23 views
      0 likes
      Last Post trilliantrader  
      Working...
      X