1

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?

sey eeet
  • 229
  • 2
  • 8

1 Answers1

2

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)
smashapalooza
  • 932
  • 2
  • 2
  • 12