New trend indicator: MSR by David Varadi
Author: Eugene
Creation Date: 10/29/2010 11:45 AM
profile picture

Eugene

#1
A New Trend Indicator: MSR

MSR= (10-day median of (H, L, C) – 20-day MAX (H, L, C))/(20-day MAX (H, L, C))
then take the 252-day percentrank of MSR or percentile ranking

QUOTE:
long trades initiated>.5
short trades are initiated<.5


I understood the "(20-day MAX (H, L, C))" as Highest High of 20 days (give it a thought).

Requires Community Indicators library installed.

CODE:
Please log in to see this code.
profile picture

thodder

#2
Hum. Does GetMedian give you the result you want? The code for GetMedian looks correct; however, it seems like you would need to sort the prices before calling GetMedian if you wanted to get the median value.
profile picture

Eugene

#3
Never hurts having someone reviewing your code as you said earlier ;)

My bad, I forgot to sort the List<double> prices before calling GetMedian. Thank you for spotting the bug.
profile picture

thodder

#4
You're welcome.

That's why I prefer to put the sort within methods like this. It is easy to forget to sort the list before you call the method. You might lose a little performance calling sort each time if it is already sorted, but most algorithms are quick if the data is already in the right order.
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).