TWP Next Bar Close Countdown


This script displays the time remaining for your charts current timeframe.period or a higher timeframe with the ability to create alerts that ping on the opening of the new bar that you have selected. It can be very easy to get bogged down in the charts when day trading on smaller timeframes and forgetting that it is the wave of longer timeframe traders that are setting the tone. This script was born out of this pitfall that I was noticing in my own trading.


The script uses a series of functions to get produce the time remaining and texts for the top and bottom rows within the table display.


1 — Resolution
  • Auto / Manual selection
    • There is tooltip explains how the automatic time selection operates (see below)
AUTO_TIMEFRAME_TOOLTIP = "When the Auto option is selected, the timeframe of the indicator is chosen automatically based on the chart timeframe. The Timeframe dropdown is ignored. The automated timeframes are: \n
 '10 minutes' for any chart timeframes below '1 minute' \n
 '1 hour' for any chart timeframes starting from '1 minute' up to '5 minutes'
 '4 hours' for any chart timeframes starting from '5 minutes' up to '60 minutes' \n
 '1 day' for any chart timeframes starting from '1 hour' up to '4 hours' \n
 '1 week' for any chart timeframes starting from '4 hours' up to '1 day' \n
 '1 month' for any timeframes starting from '1 day' up to '1 week' \n
 '3 months' for any timeframes starting from '1 week' up to '1 month' \n
 '12 months' for any timeframes above '1 month'"

2 — Text
  • Size selection
  • Color selection

3 — Display
  • Frame color selection
  • Display position selection

4 — Alerts
  • Market session selection


 • Add it to your chart, select your timeframe, change up your colors, and enjoy yourself


 • We have no control over when realtime updates occur. A realtime bar can open, and then no realtime updates can occur until the open of the next realtime bar. The time between updates can vary considerably. For more please check out Pine's execution model and bar states.

 • As a reminder, I did make this script for myself so if you find that you are using a 2-hour alert or countdown the formatting for the words may not be succinct as they should be. We will write that loss off to my growing pine skills


 • You will not be able to retrieve the time from a timeframe smaller than what is currently selected for the chart.

Please visit our website to obtain access to any of our indicators.
Protected script
This script is published closed-source and you may use it freely. You can favorite it to use it on a chart. You cannot view or modify its source code.
Want to use this script on a chart?