HighTick
Using Sharpe Ratio in TradingThe Sharpe Ratio is a measure of risk adjusted return. Although the formula was originally developed to compare the performance of mutual funds over time periods greater than 1 year, there is nothing to prevent its use in any other time frame, include intraday analysis. There are several uses of Sharpe Ratio that have been underutilized by traders:
Formula for Advancing StocksTraditionally, Sharpe Ratio analysis has been applied to stocks that are appreciating.
Note that for the Sharpe Ratio to be positive, the Annualized Average Return must be greater than the Risk Free Return. If it is used to assess potential investment in a stock, this means that the stock does not begin to become an attractive investment until its annualized average return exceeds what an investor could earn in a risk free investment, such as a CD. In many cases, the growth rate of stocks is so far in excess of the CD interest rate that the Risk Free Return factor does not contribute significantly to the value of the Sharpe Ratio. When screening for high growth rate stocks, the Risk Free Return could be considered to be zero since its contribution to the final value of Sharpe Ratio is so small. However, to be of greatest utility in evaluating all investments, including those that have relative low rates of return but high safety, the Risk Free Return component is important. Formula for Declining StocksCan we use Sharpe Ratio to evaluate potential shorts? The answer is yes, provided we modify the formula slightly:
If the Annualized Avg Return is negative, as it will be for stocks that are declining, then to find the stocks with the greatest risk adjusted decline, the Risk Free Return should be added rather than subtracted. The means that for a stock to be attractive as a short, it must have an annualized average return that is more negative than the Risk Free Return of a CD is positive. In the Sharpe Ratio code provided below, the Annualized Avg Return is calculated and depending on whether this is a positive or negative number the sign of the Risk Free Return is adjusted to be either a plus or a minus. Therefore, unlike the standard Sharpe Ratio formula, the Sharpe Ratio functions provided here can be used either to identify attractive longs or shorts without further modification. For example, in screening for potential longs and shorts, a stock with a Sharpe Ratio of +3 and a declining stock with a Sharpe Ratio of 3 represent equal opportunities to make money. We now have a way of screening the market for potential longs and shorts AND having a reasonable way to compare the relative merits of potential longs and shorts on a riskadjusted basis! The most attractive trading opportunities in both directions will be revealed by the same scan if the results are sorted in order by absolute Sharpe Ratio value! When scanning the market for potential longs and shorts, the Sharpe Ratio indicator is inserted into Radarscreen containing a large number of potential stocks to evaluate. The Sharpe Ratio and the absolute Sharpe Ratio values are displayed in separate columns. The Radarscreen is sorted in decreasing order sorted by absolute Sharpe Ratio. The best opportunities, both longs and shorts, will roll up to the top of the list. This list may be updated frequently during the day using the auto sort feature of Radarscreen. The best long opportunities will be those stocks with the highest positive Sharpe Ratio, and the best short opportunities will be those stocks with the largest negative Sharpe Ratio. Example of Scanning for Long and Shorts with Sharpe RatioA Radarscreen Sharpe Ratio indicator used for stock scanning is shown below. In this case, the NASDAQ stocks are being scanned for the best and worst riskadjusted performance during the most recent 40 days ending 1/22/10. The time period may be adjusted by the user and can be chosen to span a period of weeks, days or even intraday minutes.
Fig. 1. Radarscreen indicator scanning for best and worst riskadjusted performance These two screen captures are from the same Radarscreen indicator processing all 100 NASDAQ stocks simultaneously. The screen capture includes only the top 20 rows. The worst performing stocks (right chart) are found by simply sorting the Sharpe Ratio column (SR1) in ascending rather than descending order. The Annualized Rate of Return (AnnRR) is also displayed. In this example, the best stocks are moving either up or down at an annualized rate of return in excess of 100%. This illustrates why, when using the Sharpe Ratio function as a stock scanner, the Risk Free Rate of Return component in the formula, typically represented by the CD interest rate (25%) is often makes a relatively insignificant contribution to the Sharpe Ratio value. Other columns being displayed above are:
Fig. 2. Scan Results  Charts with best riskadjusted performance Fig. 3. Scan Results  Charts with worst riskadjusted performance Why is "riskadjusted" performance so important?The Sharpe Ratio finds stocks with trends that are strong and have "low risk", that is, trends that are wellbehaved and less volatile. This is important for two reasons:
Advantages of Sharpe Ratio as a Screening Tool
Sharpe Ratio Indicator for ChartsFig 4. Sharpe Ratio Indicator for Charts The chart above shows a running Sharpe Ratio function using a length of 20 (yellow) and a length of 50 (green). This indicator can plot up to 4 Sharpe Ratios of different lengths simultaneously to show price riskadjusted price performance in several different time frames. The most recent 20 and 50 bars show a Sharpe Ratio value of 9.34 and 6.02, respectively. This stock, PBI was identified by scanning the S&P 500 stocks for the worst performing stocks in the last 20 and 50 days, respectively. The scan is shown below: Fig 5. Sharpe Ratio scan of the S&P500 stocks, sorted to identify the worst performing stocks To identify the worst performing stocks in the S&P500 in the most recent 50 days, the Sharpe Ratio indicator for Radarscreen is being sorted in descending order by absolute Sharpe Ratio, using a length of 50 days. Sharpe Ratios for the most recent 20 and 50 days are simultaneously displayed. However, the column being sorted is the 50 day absolute Sharpe Ratio value, identifying stock PBI as the worst riskadjusted performer during the most recent 50 days. The Sharpe Ratio values for the 20 and 50 days analysis are 6.26 and 5.04, respectively. The best riskadjusted performance stocks are those shown with positive Sharpe Ratio numbers (green). RadarScreen Indicator Input ParametersPrice: The reference value used to calculate Sharpe Ratio. Using AvgPrice or TypicalPrice instead of Close will result in a somewhat smoother Sharpe Ratio function. SegLength: The number of bars used for each segment of time analyzed for rate of return. On a daily chart, if daily rate of return analysis is desired, then SegLength would be 1. If weekly analysis was desired on a daily chart, then SegLength would be 5 (5 bars on a daily chart = 1 week). SegsPerYear: The number of segments in a year. On a daily chart, SegsPerYear would be 251 (trading days in a year) if SegLength was 1. If each segment was a week's worth of data (SegLength = 5 on a daily chart), then SegsPerYear would be 52, since there are 52 weeks in a year. Segments1, Segments2: The number of segments used to perform the calculation of Sharpe Ratio. Two separate Sharpe Ratios can be calculated simultaneously in this RS indicator. Offset1, Offset2: The number of bars to the left of the current bar that the calculation is based upon. For example, if Offset1 = 1, then Sharpe Ratio 1 is the Sharpe Ratio as of the bar prior to the current bar. CalcSeconds: The minimum number of seconds between calculations. This is used to prevent frequent recalculation of Sharpe Ratio with each tick of actively trading stocks. It is useful whenever offsets are set to zero (default). This means the current bar is being used as part of the calculation. It is useful to know how the Sharpe Ratio is changing as the price of the current bar changes. However, it is not necessary to perform the recalculation with each tick of data. This setting reduces the frequency of recalculation to a more reasonable value. In this case, the default of 60 indicates the Sharpe Ratio calculation will not be performed more often than once each minute. RiskFreeReturn: This is the rate of return of a completely safe investment expressed in annual percent. Typically the current CD (certificate of deposit) rate is used. SegColor: The color used to display the length of the Sharpe Ratio calculations. Choosing a unique color, such as cyan, provides some visual separation from the two independent calculations displayed. OffsetColor, OffsetWarningColor, CalcColor: These are not yet implemented in the current version, but will be used in more sophisticated versions allowing up to 4 Sharpe Ratio time frames to be simultaneously calculated, and custom functions of all 4 results to be output. What type of custom functions? Let's say you want to scan for the best performing stocks up until the market turned 2 weeks ago that also had the worst performance during the most recent 2 weeks while the market was pulling back. You could set up Sharpe Ratio 1 to have an offset of 10 (2 weeks = 10 trading days) and a Seglength of 40. This would find the stocks that had the best performance up and until the market turned. Set up Sharpe Ratio 2 to have an offset of 0 and a Segment2 = 10 (to analyze the most recent 2 week performance). This Sharpe Ratio will find the stocks with the sharpest declines since the market turned.
MarkSanDiego
DownloadsInitial posted version: 01/30/10 Latest Update: 01/24/13 *.ELD files are compiled for TS 9.1 All ELD and code text files packaged here: The code may be visualized here: Radarscreen Indicator SharpeRatio.RS Radarscreen Indicator SharpRatioQ.RS
