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


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

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.

Please log in to see this code.
profile picture


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


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


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.