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

Quick Sort Possible for DataSeries Object?

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

    Quick Sort Possible for DataSeries Object?

    Is it possible to embed the quick sort algo for a DataSeries object within the OnBarUpdate() method? I tried to do so (quick sort the volume[] object for all the data from the beginning of the trading day to the latest bar) but the compiled indicator always freezes upon loading. I'm wondering if the DataSeries object cannot be sorted as a regular array, and if there's any built-in sorting routines for DataSeries. I was using the standard C# quick sort algo. Nothing fancy here.

    Thanks!
    Last edited by zenith1107; 05-29-2009, 02:48 AM.

    #2
    just define your private collection
    as data is coming in at onbarupdate you can do the comparison. enough to compare the new data coming in.iterating is done automatically in consecutive onbarupdate calls

    Comment


      #3
      What does that mean?

      Comment


        #4
        Something like Volume[] should not be sorted because everything is tied to the bars. You may need to transfer everything to your own array and then you can sort.
        Josh P.NinjaTrader Customer Service

        Comment


          #5
          The thing is I want to sort the volume data dynamically - sort all the data from the beginning of the trading day to the current bar, sorting once upon each new bar. My goal is to find the value that divides the sorted volume data exactly in half then return that value (which is again updated upon each new bar). Is there a way to do the sorting within the volume[] object? I'm only saying this because transferring data from volume[] dataseries to a new array dynamically probably will take an enormous amount of memory. Intuition tells me that a quicksort routine followed by a while loop might do the job without creating a new custom array.

          Comment


            #6
            Hello,

            I'm jumping the middle of this, but a loop with a mean or range/2 calculation to find the middle sounds like it will do what you want. Then you can update it on each tick (will use more resources), or update it on FirstTickOfBar to save resources.

            If that didn't help, repost and Josh will help you on Monday.
            DenNinjaTrader Customer Service

            Comment


              #7
              Originally posted by zenith1107 View Post
              ...I'm only saying this because transferring data from volume[] dataseries to a new array dynamically probably will take an enormous amount of memory. Intuition tells me that a quicksort routine followed by a while loop might do the job without creating a new custom array.
              Hard for me to imagine that creation of an additional datastructure for proccessing the volume-values for every bar on the chart has any considerable impact to memory usage. If you would use a SortedList you wouldn't need to think about sorting procedures as well.

              Regards
              Ralph

              Comment


                #8
                Zenith107,

                so you want to find the past bar when half of the current days volume has been traded? Do I understand correctly?


                Why don't you use a Volume chart instead of a time chart?

                For example set every chart bar to volume 1000

                Then you know the total volume by multiplying the volume per bar by the number of bars elapsed.
                And half the volume is simply half that number of bars back from current.

                regards

                Comment


                  #9
                  hello all,

                  I also wanted to sort on volume as in the beginning of this thread. I would sort on FirstTickOfBar and would want to sort to find the highest, then second highest, then third highest and ... etc.

                  I found this:
                  "HighestBar(Volume, Bars.BarsSinceSession-1)"

                  but it only gives me the highest of the day as each new higher volume bar of the day comes along.

                  So what I want to know is if there is a way to sort past volume bars into a list of highest to lowest.

                  Thanks,


                  taddypole...

                  Comment

                  Latest Posts

                  Collapse

                  Topics Statistics Last Post
                  Started by NRITV, Today, 01:15 PM
                  2 responses
                  6 views
                  0 likes
                  Last Post NRITV
                  by NRITV
                   
                  Started by frankthearm, Today, 09:08 AM
                  7 responses
                  30 views
                  0 likes
                  Last Post NinjaTrader_Clayton  
                  Started by maybeimnotrader, Yesterday, 05:46 PM
                  5 responses
                  25 views
                  0 likes
                  Last Post NinjaTrader_ChelseaB  
                  Started by quantismo, Yesterday, 05:13 PM
                  2 responses
                  18 views
                  0 likes
                  Last Post quantismo  
                  Started by adeelshahzad, Today, 03:54 AM
                  5 responses
                  33 views
                  0 likes
                  Last Post NinjaTrader_BrandonH  
                  Working...
                  X