Countdown Clock to bar close in ThinkorSwim?

anycolour

Member
Hey guys. I've been using tick charts and I like that it tells you how many ticks have passed in the formation of a new 1k tick candle (you can count how many are left until a new candle forms). In the attached screenshot, it says 960, that means 960 trades/ticks have been made in that candle (meaning 40 remain to fully form that candle, and then a new candle will be formed with another 1k ticks/trades).

I want to do that with the 5m chart (time chart, not tick).
Is there an indicator that could tell me the remaining minutes and seconds until the formation of a new 5m candle? A countdown for the formation of 5 minute candles. Thank you!

bUTSDS9.jpg
 

Attachments

  • bUTSDS9.jpg
    bUTSDS9.jpg
    82.1 KB · Views: 560
Last edited by a moderator:
Hi all,


I am trying to add the 1 minute display count on the last current candle from my chart but I am getting the error on this line

def bars = BarNumber() - HighestAll(if SecondsFromTime(0) < 60, BarNumber());

Here is my script that I am working on:

input aggregationPeriod = AggregationPeriod.MIN;

def bars = BarNumber() - HighestAll(if SecondsFromTime(0) < 60, BarNumber());

plot count = if GetAggregationPeriod() == aggregationPeriod then bars else Double.NaN;
count.SetPaintingStrategy(PaintingStrategy.VALUES_ABOVE);
count.AssignValueColor(Color.WHITE);

Anyone can see if there is anything wrong with the script?

Here is a countdown timer workaround that may help you.

Create a grid. See the example of one in the image below.

Set chart timeframe to 1 minute... input aggregation you want to time... time will countdown in whole minutes (sorry, as I have advised you before, no seconds are possible at this time)... the final minute will appear in red. There is an option if you want a sound alert when the timer changes.

Put the script in the bottom right cell of the grid. Hide the price graph for that cell in chart setttings.

The image shows a 5min chart to be counted down. The time is at 11:16:59. The timer in the lower right cell of the grid shows 4 in color.white. When there is one minute left, it will turn color.red.
Screenshot-2023-03-23-144825.png
Code:
#Bar Minute Timer
#Set chart timeframe to 1 minute... input aggregation you want to time... time will countdown in whole minutes (sorry no seconds are possible at this time)... the final minute will appear in red
declare lower;
HidePricePlot();
input aggregation = 5;
input showverticalline = no;
input begin   = 0930;
input end     = 1600;
def bar       = if SecondsTillTime(begin) == 0 and
                   SecondsFromTime(begin) == 0
                then 0
                else bar[1] + 1;
AddVerticalLine(if showverticalline and GetDay() == GetLastDay() and SecondsFromTime(begin) >= 0
                then bar % ((Ceil(aggregation)) / (GetAggregationPeriod() / 60000)) == 0
                else Double.NaN,
                color = Color.BLUE, stroke = Curve.FIRM);


def start = if GetDay() == GetLastDay() and SecondsFromTime(begin) >= 0
                then aggregation - bar % ((Ceil(aggregation) * 1))
                else start[1];
input bubblemover = -1;
def x  = bubblemover;
def x1 = x + 1;
AddChartBubble(!IsNaN(close[x1]) and IsNaN(close[x]), 0, " \n" + start[x1] + " \n  ", if start[x1] > 1 then Color.WHITE else Color.RED );
AddLabel(!IsNaN(close[x1]) and IsNaN(close[x]), start[x1], if start[x1] > 1 then Color.WHITE else Color.RED );

input usealert = no;
Alert(usealert and start == aggregation, "", Alert.BAR, Sound.Chimes);
 
Here is a countdown timer workaround that may help you.

Create a grid. See the example of one in the image below.

Set chart timeframe to 1 minute... input aggregation you want to time... time will countdown in whole minutes (sorry, as I have advised you before, no seconds are possible at this time)... the final minute will appear in red. There is an option if you want a sound alert when the timer changes.

Put the script in the bottom right cell of the grid. Hide the price graph for that cell in chart setttings.

The image shows a 5min chart to be counted down. The time is at 11:16:59. The timer in the lower right cell of the grid shows 4 in color.white. When there is one minute left, it will turn color.red.
It's great !!! , thank you very much, if you find a way to have a countdown of 1 minute either expressed in numbers or visually it will be a genius for us scalper, thanks for your contribution
 
Hi I’m looking for a count down that sounds an alarm in 20 minute intervals. If anyone can assist
I've been using a script that does that for any interval. It uses the built in TOS sounds...just don't use the "Chimes" sound. Thats the sound when you get a fill. It scares the crap out of me.lol.

It also plots a vertical line, and send you alert message.

It is based on this post:
https://usethinkscript.com/threads/...-close-in-thinkorswim.1056/page-2#post-102971


Code:
# bar timer adds a vertical line 1 min before the interval_In_Minutes in minutes elapses
input StartTime = 0930;
input Interval_In_Minutes = 30;
def AftrStartTime = SecondsFromTime(StartTime - 1) > 59;
def StartPoint = !AftrStartTime[1] and AftrStartTime;
def MinutesGoneBy = if AftrStartTime then SecondsFromTime(StartTime) / 60 else 0;
def IntervalPast = if AftrStartTime then
RoundDown(MinutesGoneBy / Interval_In_Minutes, 0) else 0;
def IntervalPoint = IntervalPast > IntervalPast[1];
rec MinutesPastInterval = if IntervalPoint or StartPoint then 0 else
MinutesPastInterval[1] + 1;
AddVerticalLine( IntervalPoint , Interval_In_Minutes + " min", Color.GRAY, curve.SHORT_DASH);
Alert(IntervalPoint == 1, " ", Alert.BAR, Sound.Chimes);
 

Attachments

  • Screen Shot 2023-05-18 at 3.21.09 PM.png
    Screen Shot 2023-05-18 at 3.21.09 PM.png
    28.2 KB · Views: 274
  • Screen Shot 2023-05-18 at 3.22.38 PM.png
    Screen Shot 2023-05-18 at 3.22.38 PM.png
    26.7 KB · Views: 283
Last edited by a moderator:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
484 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top