среда, 29 апреля 2020 г.

Yang-Zhang

https://ru.tradingview.com/script/Z5qQonM6-Yang-Zhang-Volatility/

//@version=3
study("Yang-Zhang Volatility")
n1 = input(20,"N Value")
averageP = input(200,"Average Length")

No = log(open) - log(close[1])  // normalized open
Nu = log(high) - log(open)      // normalized high
Nd = log(low) - log(open)       // normalized low
Nc = log(close) - log(open)     // normalized close

Vrs = 1 / n1 * sum((Nu * (Nu - Nc) + Nd * (Nd - Nc)),n1)  // RS volatility estimator

Noavg = 1 / n1 * sum(No,n1)
Vo = 1 / (n1 - 1) * sum(pow((No - Noavg),2),21)

Ncavg = 1 / n1 * sum(Nc,n1)
Vc = 1 / (n1 - 1) * sum(pow((Nc - Ncavg),2),21)

k = 0.34 / ( 1.34 + (n1 + 1) / (n1 - 1))

Vyangzhang = Vo + k * Vc + (1 - k) * Vrs

avg = sma(Vyangzhang,averageP)

plot(Vyangzhang,color=fuchsia,linewidth=2,transp=50,style=area,title="Volatility")
plot(avg,color=aqua,linewidth=2,transp=0,title="Avg Volatility")

https://www.atmif.com/papers/range.pdf

Комментариев нет:

Отправить комментарий