OPEN-SOURCE SCRIPT

CNN Fear and Greed Index JD modified from minusminus

CNN Fear and Greed Index - https://www.cnn.com/markets/fear-and-greed

Modified from minusminus -
CNN Fear and Greed Index


See Documentation from CNN's website
CNN's Fear and Greed index is an attempt to quantitatively score the Fear and Greed in the SPX using 7 factors:
  1. Market Momentum- S&P 500 (SPX) and its 125-day moving average
  2. Stock Price Strength -Net new 52-week highs and lows on the NYSE
  3. Stock Price Breadth - McClellan Volume Summation Index
  4. Put and Call options - 5-day average put/call ratio
  5. Market Volatility - VIX and its 50-day moving average
  6. Safe Haven Demand - Difference in 20-day stock and bond returns
  7. Junk Bond Demand - Yield spread: junk bonds vs. investment grade


Each Factor has a weight input for the final calculation initially set to a weight of 1. The final calculation of the index is a weighted average of each factor.

3 Factors have separate functions for calculation: See Code for Clarity

  1. SPX Momentum: difference between the Daily SPX index value and it's 125 Day Simple moving average.
  2. Stock Price Strength: Net New 52-week highs and lows on the NYSE.
    Function calculates a measure of Net New 52-week highs by:
    NYSE 52-week highs (INDEX:MAHN) - all new NYSE Highs (INDEX:HIGH)
    measure of Net New 52-week lows by:
    NYSE 52-week lows (INDEX:MALN) - all new NYSE Lows (INDEX:LOWN)
    Then calculate a ratio of Net New 52-week Highs and Lows over Total Highs and Lows then takes a 5-day moving average of that ratio-See Code
  3. Stock Price Breadth is the McClellan Volume Summation Index:
    First Calculate the McClellan Oscillator
    Second Calculate the Summation Index


4 Factors are Straight data requests
  1. 5 Day Simple Moving Average of the Put-Call Ratio on SPY
  2. 50 Day Simple Moving Average of the SPX VIX
  3. Difference between 20 Day Simple Moving Average of SPX Daily Close and 20 Day Simple Moving Average of 10Y Constant Maturity US Treasury Note
  4. Yield Spread between ICE BofA US High Yield Index and ICE BofA US Investment Grade Corporate Yield Index


The Fear and Greed Index is a weighted average of these factors - which is then normalized to scale from 0 to 100 using the past 25 values - length parameter.

3 Zones are Shaded: Red for Extreme Fear, Grey for normal jitters, Green for Extreme Greed.

Disclaimer: This is not financial advice. These are just my ideas, and I am not an investment advisor or investment professional. This code is for informational purposes only and do your own analysis before making any investment decisions. This is an attempt to replicate in spirt an index CNN publishes on their website and in no way shape or form infringes on their content, calculations or proprietary information.




From CNN: https://www.cnn.com/markets/fear-and-greed

FEAR & GREED INDEX FAQs
What is the CNN Business Fear & Greed Index?

The Fear & Greed Index is a way to gauge stock market movements and whether stocks are fairly priced. The theory is based on the logic that excessive fear tends to drive down share prices, and too much greed tends to have the opposite effect.

How is Fear & Greed Calculated?

The Fear & Greed Index is a compilation of seven different indicators that measure some aspect of stock market behavior. They are market momentum, stock price strength, stock price breadth, put and call options, junk bond demand, market volatility, and safe haven demand. The index tracks how much these individual indicators deviate from their averages compared to how much they normally diverge. The index gives each indicator equal weighting in calculating a score from 0 to 100, with 100 representing maximum greediness and 0 signaling maximum fear.

How often is the Fear & Greed Index calculated?

Every component and the Index are calculated as soon as new data becomes available.

How to use Fear & Greed Index?

The Fear & Greed Index is used to gauge the mood of the market. Many investors are emotional and reactionary, and fear and greed sentiment indicators can alert investors to their own emotions and biases that can influence their decisions. When combined with fundamentals and other analytical tools, the Index can be a helpful way to assess market sentiment.
sentiment

Script open-source

Dans le plus pur esprit TradingView, l'auteur de ce script l'a publié en open-source, afin que les traders puissent le comprendre et le vérifier. Bravo à l'auteur! Vous pouvez l'utiliser gratuitement, mais la réutilisation de ce code dans une publication est régie par nos Règles. Vous pouvez le mettre en favori pour l'utiliser sur un graphique.

Vous voulez utiliser ce script sur un graphique ?


just trying to make a living
Aussi sur:

Clause de non-responsabilité