The 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:
- Scanning. Compare large numbers of individual stocks and find those which have the largest risk adjusted gain over much smaller time frames, including intraday analysis.
- Longs vs. Shorts. Compare the relative merits of potential shorts and longs on a risk adjusted basis.
- To Trade or Not. Determine if the price action supports making a trade at all, compared to lower risk investment alternatives.
Formula for Advancing Stocks
Traditionally, Sharpe Ratio analysis has been applied to stocks that are appreciating.
Sharpe Ratio | = | Annualized Avg Return (%) – Risk Free Return (e.g. CD Rate) |
Annualized Std Dev of Returns |
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 Stocks
Can we use Sharpe Ratio to evaluate potential shorts? The answer is yes, provided we modify the formula slightly:
Sharpe Ratio | = | Annualized Avg Return (%) + Risk Free Return (e.g. CD Rate) |
Annualized Std Dev of Returns |
Example of Scanning for Long and Shorts with Sharpe Ratio
Best Performing Stocks – NASDAQ 100 – 40 Days
Worst Performing Stocks – NASDAQ 100 – 40 Days


Fig. 1. Radarscreen indicator scanning for best and worst risk-adjusted performance
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 (2-5%) is often makes a relatively insignificant contribution to the Sharpe Ratio value.
Other columns being displayed above are:
- SegLen: The number of bars in one segment. A segment is the length of the period used to calculate the gains in the Sharpe Ratio formula. In this case, the daily gains are being calculated so the length = 1 on a daily chart.
- Segs: The number of segments to be analyzed




Fig. 2. Scan Results – Charts with best risk-adjusted performance




Fig. 3. Scan Results – Charts with worst risk-adjusted performance
Why is “risk-adjusted” performance so important?
The Sharpe Ratio finds stocks with trends that are strong and have “low risk”, that is, trends that are well-behaved and less volatile. This is important for two reasons:
- Well-behaved trends have a greater probability of continuing. If you want to trade a trend, improving the likelihood the trend will extend will improve profits.
- A low-volatility trend can be followed with a tighter trailing stop. This means, that when the trend finishes and you are stopped out by the trailing stop, you will lose or “give back” less of your profit. It does not matter if you are going long or short. In both cases, if the trend is strong AND well-behaved, you retain higher profits from your trade if you trail a tighter stop while the trend is continuing.
Advantages of Sharpe Ratio as a Screening Tool
- Reduces number of potential charts to review, as stocks with unacceptable volatility are automatically filtered out.
- Works independently of market timing. Finds well-behaved long and short opportunities regardless of market direction.
- This single indicator can be used for identifying BOTH potential Longs and Shorts.
- Compares profit potential of Longs vs. Shorts in addition to Longs vs. Longs
- The modified Sharpe Ratio formula automatically eliminates declining stocks as potential Shorts if their price is less than $5 since stocks in this price range cannot be shorted.
- Adjusts performance for risk.
- Automatically filters out large gap moves as a result of “news” events, since these events represent high volatility which is penalized in the SR formula. Abrupt gap moves do not present much opportunity for traders as the move is over by the time it is recognized and is unlikely to continue in the near future. In contrast, a steady, well-behaved price movement presents greater opportunities for profit by riding the trend.
Sharpe Ratio Indicator for Charts

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:

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 risk-adjusted 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 risk-adjusted performance stocks are those shown with positive Sharpe Ratio numbers (green).
RadarScreen Indicator Input Parameters
Price: 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.
If you noted that the market pulled back two weeks ago, and wanted to scan for the best-performing stocks just prior to the pull-back, you could use Offset1 = 10 (2 weeks is 10 trading days).
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 re-calculation with each tick of data. This setting reduces the frequency of re-calculation 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.
Now, create a custom function = SR1 minus SR2. This custom function will find the stocks with the best performance for the 2 month period before the market turned AND the worst pull-backs since the market turn. When the market downward trend is over, such stocks may be excellent long candidates, as they have demonstrated both high volatility and a concordance with the overall market movement.
Downloads
Initial 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:
Users of earlier versions fo Tradestation may compile the code
from the etext files included in the above *.zip file.
The code may be visualized here:
Radarscreen Indicator SharpeRatio.RS