Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- study("Yang-Zhang Volatility")
- // Yang-Zhang Volatility
- // source: http://http://www.todaysgroep.nl/media/236846/measuring_historic_volatility.pdf
- //
- // Rewrite for Tradingview "Pine Script" by Kocurekc, April 2014
- // https://getsatisfaction.com/tradingview/
- // https://www.tradingview.com/u/kocurekc/
- // Code is provided as public domain, no warranty
- len = input(title="Lookback Period", type=integer, defval=14, minval=2)
- F = 1
- A = log(high/close)
- B = log(high/open)
- C = log(low/close)
- D = log(low/open)
- sigRS = pow(sum(A*B + C*D,len)/len,0.5)
- k=0.34/(1.34 + (len+1)/(len-1))
- OC1 = log(open/close[1])
- CO = log(close/open)
- sigOV = (1/(len-1))*sum(pow(OC1 - sma(OC1,len),2),len)
- sigOC = (1/(len-1))*sum(pow(CO - sma(CO,len),2),len)
- sigYC = pow((sigOV + k*sigOC + (1 - k)*sigRS),0.5)
- hline(0.1, linestyle=dashed)
- plot(sigYC)
- plot(ema(sigYC,14))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement