Niklaus

Alpha strategy - simple version

This Strategy goes long when Sharpe Ratio is > 1 and Alpha against the S&P500 is generated. It exits when conditions break away. en.wikipedia.org/wiki/Alpha_(finance). Use on daily or 5min.
오픈 소스 스크립트

이 스크립트의 오써는 참된 트레이딩뷰의 스피릿으로 이 스크립트를 오픈소스로 퍼블리쉬하여 트레이더들로 하여금 이해 및 검증할 수 있도록 하였습니다. 오써를 응원합니다! 스크립트를 무료로 쓸 수 있지만, 다른 퍼블리케이션에서 이 코드를 재사용하는 것은 하우스룰을 따릅니다. 님은 즐겨찾기로 이 스크립트를 차트에서 쓸 수 있습니다.

면책사항

이 정보와 게시물은 TradingView에서 제공하거나 보증하는 금융, 투자, 거래 또는 기타 유형의 조언이나 권고 사항을 의미하거나 구성하지 않습니다. 자세한 내용은 이용 약관을 참고하세요.

차트에 이 스크립트를 사용하시겠습니까?
//@version=2
strategy("Alpha strategy - simple version", overlay=true)

//by NIKLAUS
//USE ON DAILY TIMEFRAME TO DETECT MOMO STOCKS & ETFs AND TRADE THEM
//USE ON 5MIN CHART FOR INTRADAY USAGE
//examples to try this on: GER30, NAS100, JPN225, AAPL, IBB, TSLA, FB, etc.

//This Strategy goes long when Sharpe Ratio is > 1 and Alpha against the S&P500 is generated. It exits when conditions break away.

//https://en.wikipedia.org/wiki/Alpha_(finance)
//------------------------------------------------------------------------------------------------------------------------------------
//Alpha is a measure of the active return on an investment, the performance of that investment compared to a suitable market index. 
//An alpha of 1% means the investment's return on investment over a selected period of time was 1% better than the market during that same period, 
//an alpha of -1 means the investment underperformed the market. 
//Alpha is one of the five key measures in modern portfolio theory: alpha, beta, standard deviation, R-squared and the Sharpe ratio.


//simplified sharpe
src = ohlc4, len = input(180, title = "Sharpe/Alpha/Beta Period")
pc = ((src - src[len])/src)
std = stdev(src,len)
stdaspercent = std/src
sharpe = pc/stdaspercent


//alpha
sym = "SPX500", res=period, src2 = close
ovr = security(sym, res, src2)

ret = ((close - close[1])/close)
retb = ((ovr - ovr[1])/ovr)
secd = stdev(ret, len), mktd = stdev(retb, len)
Beta = correlation(ret, retb, len) * secd / mktd

ret2 = ((close - close[len])/close)
retb2 = ((ovr - ovr[len])/ovr)

alpha = ret2 - retb2*Beta
//plot(Beta, color=green, style=area, transp=40)


smatrig = input(title="Sensitivity", type=integer, defval=2, minval=1, maxval=3) 
bgcolor (sma(sharpe,len/smatrig) > 1 and sma(alpha,len/smatrig) > 0 ? green : red, transp=70)

if (close > open) and (sma(sharpe,len/smatrig) > 1) and (sma(alpha,len/smatrig) > 0)
    strategy.entry("Alpha", strategy.long)
strategy.close("Alpha", when = (sma(sharpe,len/smatrig) < 1) or (sma(alpha,len/smatrig) < 0))