Access current time in second granularity

QQQ

New member
I'm looking to build volume/second indicator to show if a stock is about to breakout. A breakout in buy or selloff is usually associated with a massive volume increase compared to the previous candle. But if we wait for the end of the current candle to confirm it, it might be too late to enter the trade. Volume/second will show this trend is just seconds.

But I could not access current time in second or elapsed seconds of a candle stick. I've tried
Code:
SecondsFromTime/SecondsTillTime
functions. They won't help as they round up to the minutes.

Any kind help is much appreciated. Thanks 🙏!
 
I'm looking to build volume/second indicator to show if a stock is about to breakout. A breakout in buy or selloff is usually associated with a massive volume increase compared to the previous candle. But if we wait for the end of the current candle to confirm it, it might be too late to enter the trade. Volume/second will show this trend is just seconds.

But I could not access current time in second or elapsed seconds of a candle stick. I've tried
Code:
SecondsFromTime/SecondsTillTime
functions. They won't help as they round up to the minutes.

Any kind help is much appreciated. Thanks 🙏!
I tried to do something similar before. What I found is that the SecondsFromTime and SecondsTillTime functions only update one tick per candle when using a candle chart. They update in realtime / constantly when using a tick chart. So you can get the information you need by using a tick chart, and maybe there's a workaround to aggregating the volume that occurs within each minute period while the tick chart is open. But it ****s and is quite limiting, I mean it also frustrated me, that the SecondsFromTime and SecondsTillTime functions don't work in continuous realtime when a candle period is used for the chart.
 

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

Thanks @lmk99. Do you know if we can use tick chart data in ThinkScript? I can’t find such data. The closest I came to is
Code:
TickSize/TickValue
I'm not sure. If you search for "Welkin" and/or "tick volume projection" there's a fantastic study by Welkin that projects positive or negative volume changes based on tick volume. Not sure exactly how it works but if you find that study on the forums and look at the code it may help answer your question.
 
I actually looked at Welkin's code on the tick projection before opening this thread. The fundamental difference between my idea and his code is I'm trying to do current velocity and he did projection, which does not need "down to second" candle stick access. The closest of his code to what I need is:
Code:
def NA = Double.NaN;
input aggregationInSeconds = 60;
input elapsedPercentSmoothValue = 5;
input elapsedProjectionDivisor = 2;
def start = 0000;
def end = 1600;
def o = open;
def h = high;
def l = low;
def c = close;
def v = volume;
def bb = Max(o, c) == c;
def min = Floor(SecondsFromTime(start) / aggregationInSeconds);
def till = SecondsTillTime(end) / aggregationInSeconds;
def test = min != min[1];
def vc = if test and !test[1] then v else if !test then vc[1] + v else vc[1];
def secondselapsed = (AbsValue(till - Ceil(till)) * aggregationInSeconds);
But even secondselapsed is still rounded at a minute mark.

I've looked into TD Ameritrade streaming API too. The API can provide realtime quote but not volume. Volume is returned within a minute timeframe.
Chart provides streaming one minute OHLCV (Open/High/Low/Close/Volume) for a one minute period .

At this point, I think I've dug up the whole internet. And my conclusion is ThinkScript is simply not providing tools to make this feasible. Which, I think, is a really simple implementation for them, just exposing getting time with second API or providing seconds elapsed in a candle stick API.

I plan to email them at [email protected]. But my voice alone maybe small or this option is not even the best way to request. Do you have any recommendation to do this, @lmk99? Maybe our forum has a strong connection to them at some specific channel that we can voice up?
 
Last edited:
I actually looked at Welkin's code on the tick projection before opening this thread. The fundamental difference between my idea and his code is I'm trying to do current velocity and he did projection, which does not need "down to second" candle stick access. The closest of his code to what I need is:
Code:
def NA = Double.NaN;
input aggregationInSeconds = 60;
input elapsedPercentSmoothValue = 5;
input elapsedProjectionDivisor = 2;
def start = 0000;
def end = 1600;
def o = open;
def h = high;
def l = low;
def c = close;
def v = volume;
def bb = Max(o, c) == c;
def min = Floor(SecondsFromTime(start) / aggregationInSeconds);
def till = SecondsTillTime(end) / aggregationInSeconds;
def test = min != min[1];
def vc = if test and !test[1] then v else if !test then vc[1] + v else vc[1];
def secondselapsed = (AbsValue(till - Ceil(till)) * aggregationInSeconds);
But even secondselapsed is still rounded at a minute mark.

I've looked into TD Ameritrade streaming API too. The API can provide realtime quote but not volume. Volume is returned within a minute timeframe.


At this point, I think I've dug up the whole internet. And my conclusion is ThinkScript is simply not providing tools to make this feasible. Which, I think, is a really simple implementation for them, just exposing getting time with second API or providing seconds elapsed in a candle stick API.

I plan to email them at [email protected]. But my voice alone maybe small or this option is not even the best way to request. Do you have any recommendation to do this, @lmk99? Maybe our forum has a strong connection to them at some specific channel that we can voice up?

There is a thread about requesting features: https://usethinkscript.com/threads/...ome-changes-or-functions-we-want-to-see.6302/

I think posting there and making a petition maybe (?) and linking the petition to get signatures? I'm not sure what would be the best approach to trying to be heard about this. But I imagine a lot of people want this. Hope the thread helps get you in the right direction!
 
  • Like
Reactions: QQQ

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
558 Online
Create Post

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