Thanks!
Announcement
Collapse
No announcement yet.
Partner 728x90
Collapse
NinjaTrader
Quick Sort Possible for DataSeries Object?
Collapse
X
-
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.Tags: None
-
-
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
-
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
-
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.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.
Regards
Ralph
Comment
-
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
-
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 Geovanny Suaza, 02-11-2026, 06:32 PM
|
0 responses
599 views
0 likes
|
Last Post
|
||
|
Started by Geovanny Suaza, 02-11-2026, 05:51 PM
|
0 responses
344 views
1 like
|
Last Post
|
||
|
Started by Mindset, 02-09-2026, 11:44 AM
|
0 responses
103 views
0 likes
|
Last Post
by Mindset
02-09-2026, 11:44 AM
|
||
|
Started by Geovanny Suaza, 02-02-2026, 12:30 PM
|
0 responses
558 views
1 like
|
Last Post
|
||
|
Started by RFrosty, 01-28-2026, 06:49 PM
|
0 responses
557 views
1 like
|
Last Post
by RFrosty
01-28-2026, 06:49 PM
|

Comment