OPEN-SOURCE SCRIPT

GVZ Sintético (Realized Vol do Ouro)

63
//version=6
indicator("GVZ Sintético (Realized Vol do Ouro)", overlay=false)

// === INPUTS ===
lookback_days = input.int(30, "Janela (dias)", minval=2)
freq = input.int(252, "Frequência anual", options=[252,365])
ma_len = input.int(5, "Suavização (SMA)", minval=1)

// === CÁLCULO VOL REALIZADA ===
src = close
ret = math.log(src / src[1])
rv_daily = ta.stdev(ret, lookback_days)
rv_annual = rv_daily * math.sqrt(freq)
rv_smooth = ta.sma(rv_annual, ma_len)

// === PLOT ===
plot(rv_smooth * 100, title="GVZ Sintético (%)", linewidth=2, color=color.blue)
hline(10, "10%", color=color.gray)
hline(20, "20%", color=color.gray)
hline(30, "30%", color=color.gray)

Disclaimer

The information and publications are not meant to be, and do not constitute, financial, investment, trading, or other types of advice or recommendations supplied or endorsed by TradingView. Read more in the Terms of Use.