// RealVol - Realized Volatility // // https://www.realvol.com/VolFormula.htm // https://www.realvol.com/VolatilityFormula2.html // https://www.tradingview.com/script/RQoAVFgj-Realized-Volatility/ // https://www.wallstreetmojo.com/realized-volatility/ // https://journals.plos.org/plosone/article?id=10.1371/journal.pone.0102940 // //Periods = 10 //MAperiods = 20 //MAtype = 0 //0=sma, 1=ema, 2=wma, 3=Wild.MA, 4=Triang.MA, 5=EndPoint MA, 6=Time Series MA Periods = max(1,min(999,Periods)) MAperiods = max(1,min(999,MAperiods)) MAtype = max(0,min(6,MAtype)) IF BarIndex > 0 THEN R = Log(close) - Log(close[1]) //or Log(close / close[1]) VolReal = Sqrt(summation[Periods](Square(R))) * 100 Avg = Average[MAperiods,MAtype](VolReal) ENDIF RETURN VolReal AS "Realized Volatility",Avg AS "RV Average"