Reputation: 15
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)
Upvotes: 1
Views: 468
Reputation: 3818
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)
Upvotes: 2