本页源码来自 TradingView 公开发布的开源脚本,版权归原作者所有, 请遵循其原始许可(Pine 脚本常见 CC BY-NC-SA / MPL-2.0 / MIT)。 本项目仅用于研究检索与许可范围内的移植。
//@version=6
// Educational market-mood gauge. Not financial advice. Method: nuvogold.com/method/
indicator("Gold Fear & Greed Index (Nuvo Gold)", shorttitle="Gold Fear & Greed", format=format.price, precision=1)
len = input.int(252, "Percentile window (trading days)", minval=60)
smaLen = input.int(125, "Momentum average (days)", minval=20)
showBox = input.bool(true, "Show reading box")
[momS, strS] = request.security("COMEX:GC1!", "D", [ta.percentrank(close / ta.sma(close, smaLen) - 1, len), math.max(0, math.min(100, (ta.rsi(close, 14) - 30) / 40 * 100))])
volS = request.security("CBOE:GVZ", "D", 100 - ta.percentrank(close, len))
usdS = request.security("TVC:DXY", "D", 100 - ta.percentrank(close, len))
idx = (momS + strS + volS + usdS) / 4
col = idx < 25 ? #ff6b5b : idx < 45 ? #ff9d5b : idx <= 55 ? #ffd66b : idx <= 75 ? #a8d96b : #35d49a
zone = idx < 25 ? "Extreme fear" : idx < 45 ? "Fear" : idx <= 55 ? "Neutral" : idx <= 75 ? "Greed" : "Extreme greed"
h0 = hline(0, "", color.new(color.gray, 100))
h25 = hline(25, "Extreme fear", color.new(#ff6b5b, 50), hline.style_dashed)
h45 = hline(45, "Fear / Neutral", color.new(color.gray, 75), hline.style_dotted)
h55 = hline(55, "Neutral / Greed", color.new(color.gray, 75), hline.style_dotted)
h75 = hline(75, "Extreme greed", color.new(#35d49a, 50), hline.style_dashed)
h100 = hline(100, "", color.new(color.gray, 100))
fill(h0, h25, color.new(#ff6b5b, 88))
fill(h75, h100, color.new(#35d49a, 88))
plot(idx, "Gold Fear & Greed", col, 2)
plot(volS, "Volatility (GVZ, inverted)", display=display.data_window)
plot(momS, "Momentum vs 125-day average", display=display.data_window)
plot(strS, "Strength (RSI)", display=display.data_window)
plot(usdS, "US dollar (inverted)", display=display.data_window)
var table box = table.new(position.top_right, 1, 2, bgcolor=color.new(#0b1020, 15), border_width=0)
table.cell(box, 0, 0, showBox ? str.tostring(idx, "#.0") + " " + zone : "", text_color=col, text_size=size.large)
table.cell(box, 0, 1, showBox ? "Nuvo Gold | nuvogold.com" : "", text_color=color.new(color.white, 35), text_size=size.small)
alertcondition(ta.crossunder(idx, 25), "Extreme fear", "Gold fear and greed index entered extreme fear")
alertcondition(ta.crossover(idx, 75), "Extreme greed", "Gold fear and greed index entered extreme greed")