OPEN-SOURCE SCRIPT
已更新 Fear and Greed Index [DunesIsland]

The Fear and Greed Index [DunesIsland] is a sentiment indicator designed to measure the emotions driving the stock market, specifically investor fear and greed. Fear represents pessimism and caution, while greed reflects optimism and risk-taking. This indicator aggregates multiple market metrics to provide a comprehensive view of market sentiment, helping traders and investors gauge whether the market is overly fearful or excessively greedy.How It WorksThe Fear and Greed Index is calculated using four key market indicators, each capturing a different aspect of market sentiment:
Market Momentum (30% weight)
Stock Price Strength (20% weight)
Put/Call Options (30% weight)
Market Volatility (20% weight)
Each component is normalized using a z-score over a 252-day lookback period (approximately one trading year) and scaled to a range of 0 to 100. The final Fear and Greed Index is a weighted average of these four components, with the weights specified above.Key FeaturesIndex Range: The index value ranges from 0 to 100:
Dynamic Plot Color: The plot line changes color based on the index value, visually indicating the current sentiment zone.
Reference Lines: Horizontal lines are plotted at 0, 25, 50, 75, and 100 to represent the different sentiment levels: Extreme Fear, Fear, Neutral, Greed, and Extreme Greed.
How to Interpret
This indicator is a valuable tool for contrarian investors, as extreme readings often precede market reversals. However, it should be used in conjunction with other technical and fundamental analysis tools for a well-rounded view of the market.
Market Momentum (30% weight)
- Measures how the S&P 500 (SPX) is performing relative to its 125-day simple moving average (SMA).
- A higher value indicates that the market is trading well above its moving average, signaling greed.
Stock Price Strength (20% weight)
- Calculates the net number of stocks hitting 52-week highs minus those hitting 52-week lows on the NYSE.
- A greater number of net highs suggests strong market breadth and greed.
Put/Call Options (30% weight)
- Uses the 5-day average of the put/call ratio.
- A lower ratio (more call options being bought) indicates greed, as investors are betting on rising prices.
Market Volatility (20% weight)
- Utilizes the VIX index, which measures market volatility.
- Lower volatility is associated with greed, as investors are less fearful of large market swings.
Each component is normalized using a z-score over a 252-day lookback period (approximately one trading year) and scaled to a range of 0 to 100. The final Fear and Greed Index is a weighted average of these four components, with the weights specified above.Key FeaturesIndex Range: The index value ranges from 0 to 100:
- 0–25: Extreme Fear (red)
- 25–50: Fear (orange)
- 50–75: Neutral (yellow)
- 75–100: Greed (green)
Dynamic Plot Color: The plot line changes color based on the index value, visually indicating the current sentiment zone.
Reference Lines: Horizontal lines are plotted at 0, 25, 50, 75, and 100 to represent the different sentiment levels: Extreme Fear, Fear, Neutral, Greed, and Extreme Greed.
How to Interpret
- Low Values (0–25): Indicate extreme fear, which may suggest that the market is oversold and could be due for a rebound.
- High Values (75–100): Indicate greed, which may signal that the market is overbought and could be at risk of a correction.
- Neutral Range (25–75): Suggests a balanced market sentiment, neither overly fearful nor greedy.
This indicator is a valuable tool for contrarian investors, as extreme readings often precede market reversals. However, it should be used in conjunction with other technical and fundamental analysis tools for a well-rounded view of the market.
版本注释
This update to the Fear and Greed Index [DunesIsland] introduces alert conditions to enhance its usability for traders. Now, the indicator triggers a Buy Signal when the index falls to 25 or below, indicating an Extreme Fear zone and a potential oversold condition that may present a contrarian buying opportunity. Conversely, a Sell Signal is triggered when the index rises above 75, signaling a Greed zone and a potential overbought condition that may suggest a market top. To set up these alerts in TradingView, add the indicator to your chart, click the Alert button, select "Fear and Greed: Buy Signal" or "Fear and Greed: Sell Signal," choose "Once Per Bar Close" for daily charts, and configure your preferred notification method (e.g., email, SMS, or webhook). These alerts help you act on extreme market sentiment while using the indicator’s dynamic color-coded plot and reference lines to visualize market fear and greed.版本注释
The Fear and Greed Index [DunesIsland] script has been updated to include Stochastic RSI as a fifth parameter, enhancing its ability to capture market sentiment. Previously, the index was calculated using four components—Market Momentum (S&P 500 vs. 125-day SMA), Stock Price Strength (NYSE net 52-week highs/lows), Put/Call Ratio, and VIX—weighted at 30%, 20%, 30%, and 20%, respectively. The updated script now incorporates Stochastic RSI (based on a 14-period RSI with 14,3 Stochastic parameters), with all five components equally weighted at 20% to ensure balanced contribution. This addition provides a more comprehensive view of market overbought or oversold conditions, while the core logic, normalization process, plotting, reference lines, and alert conditions remain unchanged, maintaining consistency with the original design.
开源脚本
本着TradingView的真正精神,此脚本的创建者将其开源,以便交易者可以查看和验证其功能。向作者致敬!虽然您可以免费使用它,但请记住,重新发布代码必须遵守我们的网站规则。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。
开源脚本
本着TradingView的真正精神,此脚本的创建者将其开源,以便交易者可以查看和验证其功能。向作者致敬!虽然您可以免费使用它,但请记住,重新发布代码必须遵守我们的网站规则。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。