收入线,根据输入值绘制一条线
Earning Line, plotting a line from input values
我想在电视图表上有一条线,代表给定公司每个季度的收益。我自己为每家公司输入盈利值没有问题,但需要一些帮助来创建这条线,输入是季度收益发布和相关的收益数字。我们的想法是让收益线本身出现在图表上并具有自己的比例尺,就像您使用 "compare -> add symbol" 并激活 "overlay the main chart" 选项一样。这个想法是通过时间来观察收益的增长(或缺乏),看看它如何引导股价。
这显示了季度收益、预估和股息。它将覆盖比例 None,因此它独立于图表的比例。
//@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]
现在所有线路都连接起来了。如果你想恢复一些楼梯效果,请按照代码中的注释进行操作。我在宿舍上加了点。您可以通过取消选中脚本 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)
我想在电视图表上有一条线,代表给定公司每个季度的收益。我自己为每家公司输入盈利值没有问题,但需要一些帮助来创建这条线,输入是季度收益发布和相关的收益数字。我们的想法是让收益线本身出现在图表上并具有自己的比例尺,就像您使用 "compare -> add symbol" 并激活 "overlay the main chart" 选项一样。这个想法是通过时间来观察收益的增长(或缺乏),看看它如何引导股价。
这显示了季度收益、预估和股息。它将覆盖比例 None,因此它独立于图表的比例。
//@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] 现在所有线路都连接起来了。如果你想恢复一些楼梯效果,请按照代码中的注释进行操作。我在宿舍上加了点。您可以通过取消选中脚本 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)