Fear and Greed Index on TradingView
Gauge market emotion and spot major market bottoms and tops. Understand the 7 core components of the CNN Fear & Greed Index, track crypto sentiment, and copy our free Pine Script v6 sentiment indicator.
The 7 Components of Market Fear & Greed
Rather than relying on social media opinion, institutional sentiment analysis measures quantifiable data across debt, derivatives, equity breadth, and volatility markets.
1. Market Momentum
S&P 500 performance compared against its 125-day moving average.
2. Stock Price Strength
Ratio of stocks hitting 52-week highs versus 52-week lows on the NYSE.
3. Stock Price Breadth
Trading volume in advancing stocks compared to declining stocks (McClellan Oscillator).
4. Put & Call Options Ratio
Trading volume of bearish put options relative to bullish call options.
5. Junk Bond Demand
Yield spread between high-yield junk bonds and safe corporate debt.
6. Market Volatility (VIX)
CBOE Volatility Index (VIX) measured against its 50-day moving average.
7. Safe Haven Demand
Difference in 20-day returns between equities (SPY) and safe-haven Treasury bonds (TLT).
Pine Script v6 Sentiment Model
This multi-asset script models equity momentum, volatility, and Treasury safe-haven demand directly in TradingView.
//@version=6
indicator(title="Composite Market Sentiment & Fear/Greed [Pineify]", shorttitle="Fear & Greed Index", overlay=false)
// ---------------- 1. Market Momentum Component (SPY vs 125 EMA) ----------------
spy_close = request.security("SPY", timeframe.period, close)
spy_ema125 = ta.ema(spy_close, 125)
momentum_score = math.min(100.0, math.max(0.0, 50.0 + ((spy_close - spy_ema125) / spy_ema125) * 500.0))
// ---------------- 2. Volatility Component (VIX Inverse) ----------------
vix_close = request.security("VIX", timeframe.period, close)
vix_sma50 = ta.sma(vix_close, 50)
volatility_score = math.min(100.0, math.max(0.0, 50.0 - ((vix_close - vix_sma50) / vix_sma50) * 200.0))
// ---------------- 3. Safe Haven Demand (SPY vs TLT Ratio) ----------------
tlt_close = request.security("TLT", timeframe.period, close)
ratio = spy_close / tlt_close
ratio_sma20 = ta.sma(ratio, 20)
safe_haven_score = math.min(100.0, math.max(0.0, 50.0 + ((ratio - ratio_sma20) / ratio_sma20) * 300.0))
// ---------------- Composite Fear & Greed Index ----------------
fear_greed_composite = (momentum_score * 0.40) + (volatility_score * 0.35) + (safe_haven_score * 0.25)
smoothed_index = ta.sma(fear_greed_composite, 3)
// ---------------- Color Mapping ----------------
col = smoothed_index >= 75 ? color.new(color.emerald, 0) :
smoothed_index >= 55 ? color.new(color.green, 0) :
smoothed_index <= 25 ? color.new(color.red, 0) :
smoothed_index <= 45 ? color.new(color.orange, 0) :
color.new(color.yellow, 0)
plot(smoothed_index, "Fear & Greed Score", color=col, linewidth=3)
hline(80, "Extreme Greed (80)", color=color.emerald, linestyle=hline.style_dashed)
hline(60, "Greed (60)", color=color.green, linestyle=hline.style_dotted)
hline(50, "Neutral (50)", color=color.gray, linestyle=hline.style_solid)
hline(40, "Fear (40)", color=color.orange, linestyle=hline.style_dotted)
hline(20, "Extreme Fear (20)", color=color.red, linestyle=hline.style_dashed)
Go Beyond Sentiment with Real-Time Market Insights
Track institutional options order flow, dark pool blocks, and unusual volume spikes across all US equities with Pineify.