how to get the time for "countdown to bar close" in pinescript?
I want to show the countdown to bar close in my code for the current timeframe that I am using, is there a way to do it?
how to get the time for "countdown to bar close" in pinescript?
I want to show the countdown to bar close in my code for the current timeframe that I am using, is there a way to do it?
Yes, this is doable using timenow
and time_close
. My code below will plot a label that shows how many minutes and seconds until the current bar closes. You can adjust the format as needed.
indicator("My script",overlay = true)
timeLeft = time_close - timenow
if barstate.islast
label.new(bar_index,high, str.format_time(timeLeft, 'mm:ss',syminfo.timezone) , color=color.aqua)