输入时间后,如何在接下来的几个条中添加垂直线? (pinescript)

发布于 2025-01-23 07:03:18 字数 417 浏览 1 评论 0原文

我已经尝试了此代码,但它不起作用。我试图在输入后制作垂直线10条。

//@version=5
indicator("Mulitple bars after time input", overlay = true)
 
// Date/Time Input
inp_time1 = input.time(timestamp("21 Mar 2022 00:00 +0000"), "Date", confirm = true)

var barCount1 = 0
barCount1 := inp_time1 ? 0 : barCount1 + 1

if barCount1 == 10
    line.new(bar_index, open, bar_index, close, extend = extend.both, color = color.green)

I have tried this code, but it doesn't work. I tried to make the vertical line 10 bars after the input.time

//@version=5
indicator("Mulitple bars after time input", overlay = true)
 
// Date/Time Input
inp_time1 = input.time(timestamp("21 Mar 2022 00:00 +0000"), "Date", confirm = true)

var barCount1 = 0
barCount1 := inp_time1 ? 0 : barCount1 + 1

if barCount1 == 10
    line.new(bar_index, open, bar_index, close, extend = extend.both, color = color.green)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

梦幻之岛 2025-01-30 07:03:18

删除了计数器并添加了输入时间检查,您可以将值直接添加到BAR_INDEX中,以使其向右绘制,例如:

//@version=5
indicator("Mulitple bars after time input", overlay = true)
 
// Date/Time Input
inp_time1 = input.time(timestamp("21 Mar 2022 00:00 +0000"), "Date", confirm = true)
inp_bars = input.int(10, 'Bars to the Right')

if time >= inp_time1 and time[1] < inp_time1
    line.new(bar_index + inp_bars, open, bar_index + inp_bars, close, extend = extend.both, color = color.green)

Removed the counter and added an input time check instead, you can directly add the value to the bar_index to make it plot to the right, with input for example:

//@version=5
indicator("Mulitple bars after time input", overlay = true)
 
// Date/Time Input
inp_time1 = input.time(timestamp("21 Mar 2022 00:00 +0000"), "Date", confirm = true)
inp_bars = input.int(10, 'Bars to the Right')

if time >= inp_time1 and time[1] < inp_time1
    line.new(bar_index + inp_bars, open, bar_index + inp_bars, close, extend = extend.both, color = color.green)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文