1

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) 

1 Answer 1

2

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) 
Sign up to request clarification or add additional context in comments.

4 Comments

Thanks a lot for your answer, it works perfectly! Can you help me with this one please? stackoverflow.com/questions/71980158/…
Just added the answer, you can also mark the answer as accepted if the issue is resolved, You're welcome ;)
Thank you so much! Sorry for bothering you
I want to ask again, is it possible to change the 'bar' into 'day'?

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.