Your interactive trading laboratory!
 • 
4 users online

CNN Fear & Greed Index as an Extension
This is a Feature Request with 2 votes

Hi Glitch,

I love the CNN Fear & Greed Index and so far it works almost perfect for Index trading. What do you think about making an Extension out of it and making it available in Quantacula?

Here's the Tradingview Code I'm using:

//Safe Haven Demand:
safeHavenDemand1 = security ("SPX", "D", (close - close[20]) / close * 100)
safeHavenDemand2 = security ("ZB1!", "D", (close - close[20]) / close * 100)
safeHavenDemand = safeHavenDemand1 - safeHavenDemand2

//Stock Price Breadth:
stockPriceBreadth1 = security ("UVOL", "D", close)
stockPriceBreadth2 = security ("DVOL", "D", close)
stockPriceBreadth3 = stockPriceBreadth1 - stockPriceBreadth2
ema19 = ema(stockPriceBreadth3, 19)
ema39 = ema(stockPriceBreadth3, 39)
osci = ema19-ema39
stockPriceBreadth = cum(osci)

//Market Momentum:
marketMomentum1 = security ("SPX", "D", close)
marketMomentum2 = security ("SPX", "D", sma(close,125))
marketMomentum = (marketMomentum1 - marketMomentum2) / marketMomentum1 * 100

//Stock Price Strenth:
stockPriceStrenth1 = security ("MAHN", "D", ema(close, 5))
stockPriceStrenth2 = security ("MALN", "D", ema(close, 5))
stockPriceStrenth = ema((stockPriceStrenth1 - stockPriceStrenth2) / (stockPriceStrenth1 + stockPriceStrenth2) * 100, 10)

//Put and Call Options:
putCallOptions = security ("USI:PCC", "D", sma(close, 5))

//Junk Bond Demand
junkBondDemand1 = security ("Quandl:ML/USEY|0", "D", close)
junkBondDemand2 = security ("Quandl:ML/USTRI|0", "D", close)
junkBondDemand = junkBondDemand2 - junkBondDemand1

//Market Volatility:
marketVolatility = security ("VIX", "D", close)

//Rank Results
ind_safeHavenDemand = percentrank (safeHavenDemand, 252)
ind_stockPriceBreadth = percentrank (stockPriceBreadth, 252)
ind_marketMomentum = percentrank (marketMomentum, 252)
ind_stockPriceStrenth = percentrank (stockPriceStrenth, 252)
ind_putCallOptions = 100 - percentrank (putCallOptions, 252)
ind_junkBondDemand = 100 - percentrank (junkBondDemand, 252)
ind_marketVolatility = 100 - percentrank (marketVolatility, 252)

fg = (ind_safeHavenDemand + ind_stockPriceBreadth + ind_marketMomentum + ind_stockPriceStrenth + ind_putCallOptions + ind_junkBondDemand + ind_marketVolatility) / 7

plot (fg, linewidth=2, color=black, transp=0)
hline(20, color=black, linestyle=dotted,linewidth=1)
hline(70, color=black, linestyle=dotted,linewidth=1)  
Attachment

Cancel

Responses

USI:PCC would come from the CBOE extension. Would have to make sure we could get the Quandl symbols. Then, anyone using this indicator would need to have the Quandl and CBOE extensions installed as well. CBOE just broke their data format so we first need to repair the CBOE extension.

USI:PCC would come from the CBOE extension. Would have to make sure we could get the Quandl symbols. Then, anyone using this indicator would need to have the Quandl and CBOE extensions installed as well. CBOE just broke their data format so we first need to repair the CBOE extension.
Forum Tips

Please sign in if you want to participate in our forum.

Our forum uses Markdown syntax to format posts.

To embed code snippets, enclose them in [CODE][/CODE] tags.