TradingView
piram.manickam
Oct 25, 2020 2:04 PM

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

RELIANCE INDSNSE

Description

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: investopedia.com/terms/b/beta.asp

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.
Comments
EdoardoMazzella
HI. This is Levered or Unlevered? :) thank you
piram.manickam
@EdoardoMazzella, This is levered beta
mgrathnam
excellent brother.
sendk
have crosschecked the figures with NSE , and the indicator without modifications is accurate ... great work bhai... more power to you
piram.manickam
@sendk, thanks for your good words! Credits go to the original author Ricardo Santos
Tomasinversor00
Hi bro from Mexico, wonderful indicator I've been looking something like this for months! it will be to helpful to gauge my portfolio, just one question, what does "smooth" (on the settings for the indicator) mean?
I hope you can answer me, thanks a lot!
piram.manickam
@Tomasinversor00, Thanks for your encouraging words. 'Smooth' setting helps you specify the number of days across which daily returns should be averaged.

The calculations use a daily return percentage. If you keep 'Smooth' as 1, the default, it uses the daily return percentage on a day-to-day basis as is. If you tweak 'Smooth' to say, 4, it would take the average of last 4 days daily returns for calculations than just using today's returns. If the asset has huge volatility between the days, you can consider increasing the 'Smooth' value. Otherwise you can leave it as 1.
Tomasinversor00
@piram.manickam, ok, thanks a lot for the information.
MohdAnish
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)
More