Pine script 收益线,根据输入值绘制一条线

Pine script 收益线,根据输入值绘制一条线,pine-script,Pine Script,我想在电视图表上画一条线,代表一个给定公司一个季度接一个季度的收益。我自己为每家公司输入收益值没有问题,但需要一些帮助来创建该行,输入是季度收益发布和相关收益编号。这样做的想法是将收益线放在图表上,并使用自己的比例,就像使用“比较->添加符号”并激活“覆盖主图表”选项一样。我们的想法是观察收益随时间的增长(或缺乏),并了解它如何引导股价。这显示了季度收益、估计和股息。它将覆盖在“无比例”上,因此它与图表的比例无关 //@version=4 // Unsupported security call

我想在电视图表上画一条线,代表一个给定公司一个季度接一个季度的收益。我自己为每家公司输入收益值没有问题,但需要一些帮助来创建该行,输入是季度收益发布和相关收益编号。这样做的想法是将收益线放在图表上,并使用自己的比例,就像使用“比较->添加符号”并激活“覆盖主图表”选项一样。我们的想法是观察收益随时间的增长(或缺乏),并了解它如何引导股价。

这显示了季度收益、估计和股息。它将覆盖在“无比例”上,因此它与图表的比例无关

//@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)

[编辑2019.09.03 12:29-LucF] 现在所有的线路都接通了。如果您想让楼梯效果恢复一段时间,请遵循代码中的注释。我在四分之一硬币上加了点。您可以通过取消选中脚本设置/输入中的复选框来删除它们


太棒了,非常感谢,还有一件事,是否可以调整线的比例,就像您能够“挤压”或“扩展”正常图表中的价格轴一样?从指示器的下拉菜单中,选择“按比例固定/按新的左右比例固定”。将创建另一个刻度,然后您可以独立于价格刻度挤压或扩展。太好了,谢谢!最后一件事,你认为有没有可能只通过一条线将每个季度的盈利数据与下一个季度的盈利数据联系起来?而不是在整个季度中使用平线,然后在释放时直接跳转到下一个值?
//@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)