piram.manickam

BETA (against any benchmark index - defaulted to NSE:NIFTY)

Beta value of a stock relative to benchmark index. Thanks to Ricardo Santos for the original script. This script is adapted from it.

To understand beta, refer Investopedia link: https://www.investopedia.com/terms/b/bet...

A beta value of 1 means the stock is directly correlated to benchmark index - volatility would be same as overall market.
Beta value less than 1 and greater than 0 means the stock is less volatile than the market.
Beta value more than 1 would mean the stock is more volatile than the market.
A beta value of 1.2 would roughly translate to the stock being 20% more volatile than the overall market.

A negative beta value indicates the stock is inversely correlated to market.

In the example chart, you can see the Beta value change in NSE:RELIANCE with respect to NSE:NIFTY.
Open-source script

In true TradingView spirit, the author of this script has published it open-source, so traders can understand and verify it. Cheers to the author! You may use it for free, but reuse of this code in a publication is governed by House Rules. You can favorite it to use it on a chart.

Want to use this script on a chart?

Comments

Yeah, it's working. thanks for sharing.

By the way, I also get another script, which is showing the same result.

study("Beta")
a = tickerid
b = input("NIFTY", type=symbol)
as = security(a, period, close)
bs = security(b, period, close)
chg = roc(as, 1)
chgbase = roc(bs, 1)
N = input(252)
chgbasedouble = chgbase * chgbase
sumchgbasedouble = sum( chgbase, N ) * sum( chgbase, N )
beta = (N * sum( chg * chgbase , N ) - sum( chg, N ) * sum( chgbase, N ) ) / ( N * sum( chgbasedouble, N ) - sumchgbasedouble )
plot(beta)
Reply
@MohdAnish, glad to know it is working! thanks for sharing the other script.
+1 Reply