Hi. I want to do the following:
* Step through the 5 minute bars over the last 10 days.
* For each 5 minute bar calculate the difference between each bar's open & close, which I'll call the up-move (C>O) and down-move (C<O).
* Segregate the top 20% up-moving bars and down-moving bars.
* Calculate separate averages of the top 20% up-moves and down-moves.
I will plot these averages on daily and intraday charts to identify divergences between the longer price trend and the average size of the up & down 5min moves.
I'm stumped on how to sort the values in order to segragate the top 20% up & down moves. Is there any code out there that performs this kind of logic that I can use as a template?
Thanks
Size:
Color:
1. Put the up-moving and down-moving values into two lists i.e.
List<double>.
2. Determine the 80th percentile (i.e. 1 - 20/100) for each list (see function below). These are the top 20% values.
3. Then use a delegate to search your Lists for values greater or equal than the percentile, and you'll have two new
List<double> objects containing only the Top-20 values. Here's an example using one list:
CODE:
Please log in to see this code.
Finally, here's the percentile function:
CODE:
Please log in to see this code.
Size:
Color:
Fantastic. Thanks for the help.
Size:
Color:
Eugene - In the top part of the code example you provided you are not invoking the "percentile" function that is defined below. Where in the top code block should the percentile function be called in order to accomplish the behavior you enumerated?
Size:
Color:
"Top20" in the first code snippet is the pretend output of the percentile function.
Size:
Color: