简体   繁体   中英

Earning Line, plotting a line from input values

I'd like to have a line on the TV charts that represents the earnings of a given company quarter after quarter. I have no problem in inputting the Earning value myself for each company, but need some help to create that line, the inputs are the quarter earnings release and the associated earnings number. The idea would be to have that Earnings Line on the chart itself and with its own scale, just like when you use the "compare -> add symbol" with the "overlay the main chart" option activated. The idea is to see the growth (or lack there of) of earnings through time and see how it guides the stock price.

This shows quarterly earnings, estimate and dividends. It will overlay on scale None , so it is independent of the chart's scale.

//@version=4
// Unsupported security call feature. No guarantee it will work in the future.
study("Earnings", "", true, scale = scale.none)
earnings = security("ESD:" + syminfo.prefix + "_" + syminfo.ticker + "_EARNINGS", "3M", close[1], lookahead = barmerge.lookahead_on)
estimate = security("ESD:" + syminfo.prefix + "_" + syminfo.ticker + "_EARNINGS", "3M", open[1], lookahead = barmerge.lookahead_on)
dividends = security("ESD:" + syminfo.prefix + "_" + syminfo.ticker + "_DIVIDENDS", "3M", close[1], lookahead = barmerge.lookahead_on)
plot(earnings, "Earnings")
plot(estimate, "Estimate", transp = 75)
plot(dividends, "Dividends", color.orange)

在此处输入图片说明

[EDIT 2019.09.03 12:29 — LucF] All the lines now connect. Follow comments in code if you want the staircase effect back for some. I added dots on quarters. You can remove them by unchecking the checkbox in the script's Settings/Inputs .

//@version=4
// Unsupported security call feature. No guarantee it will work in the future.
study("Earnings", "", true, scale = scale.none)
plotDots = input(true, "Plot dots")
// In order to plot in staircases instead, use "gaps = barmerge.gaps_off".
earnings    = security("ESD:" + syminfo.prefix + "_" + syminfo.ticker + "_EARNINGS", "3M",  close[1],   gaps = barmerge.gaps_on, lookahead = barmerge.lookahead_on)
estimate    = security("ESD:" + syminfo.prefix + "_" + syminfo.ticker + "_EARNINGS", "3M",  open[1],    gaps = barmerge.gaps_on, lookahead = barmerge.lookahead_on)
dividends   = security("ESD:" + syminfo.prefix + "_" + syminfo.ticker + "_DIVIDENDS", "3M", close[1],   gaps = barmerge.gaps_on, lookahead = barmerge.lookahead_on)
// Plot lines.
plot(earnings,  "Earnings")
plot(estimate,  "Estimate", transp = 75)
plot(dividends, "Dividends", color.orange)
// Plot dots.
plot(plotDots ? earnings  : na, "Earnings", style = plot.style_circles, linewidth = 3)
plot(plotDots ? estimate  : na, "Estimate", transp = 75, style = plot.style_circles, linewidth = 3)
plot(plotDots ? dividends : na, "Dividends", color.orange, style = plot.style_circles, linewidth = 3)

在此处输入图片说明

Very nice job. I have a question: I need to have a reference/list of all fundamental information available through SECURITY like _EARNINGS and _DIVIDENDS. where can I find a list of them?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM