Trailing Sharpe Ratio

The Sharpe ratio allows you to see whether or not an investment has historically provided a return appropriate to its risk level. A Sharpe ratio above one is acceptable, above 2 is good, and above 3 is excellent. A Sharpe ratio less than one would indicate that an investment has not returned a high enough return to justify the risk of holding it. Interesting in this example, SPY's one year avg Sharpe ratio is above 3. This would mean on average SPY returns 3x better returns than the risk associated with holding it, implying there is some sort of underlying value to the investment.

When the sharpe ratio is above its signal, this implies the investment is currently outperforming compared to its typical return, below the signal means the investment is currently under performing. A negative Shape would mean that the investment has not provided a positive return, and may be a possible short candidate.
從常用腳本中移除 新增至常用腳本
study("Trailing Sharpe Ratio")
src = ohlc4, len = input(252, title = "Time Frame (252 is one year)")
//mean = sma(src,len)
dividend_yield = input(0.0000, minval = 0.00001, title = "Dividend Yield? Enter as Decimal, USE 12 MONTH TTM!!!")
pc = ((src - src[len])/src) + (dividend_yield*(len/252))
std = stdev(src,len)
stdaspercent = std/src
riskfreerate = input(0.0004, minval = 0.0001, title = "risk free rate (3 month treasury yield), enter as decimal")
sharpe = (pc - riskfreerate)/stdaspercent
signal = sma(sharpe,len)
calc = sharpe - signal
plot(sharpe, style = line, color = calc < 0 ? red : green, linewidth = 2)
plot(signal, style = line, color = purple, linewidth = 2)


I get this error when trying to implement this code: "line 17 (plot command): 'line' could not be a variable or function name". Could you tell me why?
Koko0111855 Koko0111855
@Koko0111855, solved
Good boy
首頁 股票篩選器 外匯篩選器 加密貨幣篩選器 全球財經日曆 如何運作 圖表功能 價格 推薦朋友 網站規則 幫助中心 網站 & 經紀商解決方案 小工具 圖表解決方案 輕量圖表庫 部落格 & 新聞 推特
概覽 個人資料設定 賬戶和賬單 推薦朋友 我的客服工單 幫助中心 發表的想法 粉絲 正在關注 私人訊息 在線聊天 登出