A New Trend Indicator: MSRMSR= (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.
     
    
        
    
    
        
    
    
        Size:  
    
        Color:  
    
    
 
    
        
     
    
        
    
 
    
    
    
        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.
    
    
        
    
    
        
    
    
        Size:  
    
        Color:  
    
    
 
    
        
     
    
        
    
 
    
    
    
        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.
    
    
        
    
    
        
    
    
        Size:  
    
        Color:  
    
    
 
    
        
     
    
        
    
 
    
    
    
        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.
    
    
        
    
    
        
    
    
        Size:  
    
        Color: