输入时间后,如何在接下来的几根柱子上加竖线? (pinescript)

How to add vertical lines in the next several bars after input the time? (pinescript)

我试过这段代码,但它不起作用。我试图在 input.time

之后制作垂直线 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)

删除了计数器并添加了输入时间检查,您可以直接将值添加到 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)