Top 20% 5 minute up and down moves over the last 10 days
Author: cfurer
Creation Date: 6/9/2010 9:43 PM
profile picture

cfurer

#1
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
profile picture

Eugene

#2
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.
profile picture

cfurer

#3
Fantastic. Thanks for the help.
profile picture

cfurer

#4
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?
profile picture

Eugene

#5
"Top20" in the first code snippet is the pretend output of the percentile function.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).