绘制未来日期
Plot future dates
我使用直方图为每个特定日期写了一个关于垂直线的 pinescript。
PineScript
//@version=4
study("Plot vertical line with date", overlay=true)
plot((time == timestamp("GMT+0", 2021,11,11,0,0)) ? 100000 : na, color = color.rgb(255, 0, 0, 22), linewidth = 1, title = "Happy 11:11", style = plot.style_histogram)
plot((time == timestamp("GMT+0", 2022,1,1,0,0)) ? 100000 : na, color = color.rgb(255, 0, 0, 22), linewidth = 1, title = "Happy New Year 2022", style = plot.style_histogram)
问题
当我使用绘图功能设置未来日期(2022 年 1 月 1 日)时,pinescript 运行 成功但未显示在图表中。
您以后无法绘图,您需要使用 offset 参数作为解决方法。
您以后可以使用line.new()
绘制垂直线。此脚本还允许您更改脚本输入中的日期:
//@version=4
study("Plot vertical line with date", overlay=true)
t1 = input(timestamp("2021-11-23T00:00:00+00:00"), "Date", type = input.time)
if barstate.islast
line.new(t1, 0, t1, 1, xloc = xloc.bar_time, extend = extend.both)
我使用直方图为每个特定日期写了一个关于垂直线的 pinescript。
PineScript
//@version=4
study("Plot vertical line with date", overlay=true)
plot((time == timestamp("GMT+0", 2021,11,11,0,0)) ? 100000 : na, color = color.rgb(255, 0, 0, 22), linewidth = 1, title = "Happy 11:11", style = plot.style_histogram)
plot((time == timestamp("GMT+0", 2022,1,1,0,0)) ? 100000 : na, color = color.rgb(255, 0, 0, 22), linewidth = 1, title = "Happy New Year 2022", style = plot.style_histogram)
问题
当我使用绘图功能设置未来日期(2022 年 1 月 1 日)时,pinescript 运行 成功但未显示在图表中。
您以后无法绘图,您需要使用 offset 参数作为解决方法。
您以后可以使用line.new()
绘制垂直线。此脚本还允许您更改脚本输入中的日期:
//@version=4
study("Plot vertical line with date", overlay=true)
t1 = input(timestamp("2021-11-23T00:00:00+00:00"), "Date", type = input.time)
if barstate.islast
line.new(t1, 0, t1, 1, xloc = xloc.bar_time, extend = extend.both)