I want to be able to see a chart of the s&p500 price divided by its dividend per share. There are no current indicators built in tradingview to allow this that I am aware of.
In tradingview, I am able to import lots of s&p500 data from https://www.multpl.com/s-p-500-dividend or here https://data.nasdaq.com/data/MULTPL-sp-500-ratios?keyword=dividend I am currently able to import the dividend per share by adding this into the tradingview ticker symbol area in a chart: QUANDL:MULTPL/SP500_DIV_MONTH however, trading view's divide by function will not work--- SPX / QUANDL:MULTPL/SP500_DIV_MONTH--- with this imported data. So I am creating a custom indicator but I am not sure how. Here is as far as i got.
//@version=5
indicator(title="sp500 p/d", shorttitle="500p/d", format=format.price, precision=2, timeframe="", timeframe_gaps=true)
length = input.int(1, minval=1)
source = input(close, "Source")
dividend = input(QUANDL:MULTPL/SP500_DIV_MONTH)
plot(roc, color=#2962FF, title="ROC")
hline(0, color=#787B86, title="Zero Line")