Join useThinkScript to post your question to a community of 21,000+ developers and traders.
I am aware of being able to do something like declare once_per_bar; but I am unaware of any such declaration to make it constantly update. My guess is that there isn't really a way for us to do that through ToS. I may very well be mistaken, but I'm not sure that what you're after can be done. Most of ToS (and any trading thing for that matter) is built on the idea of a block of some aggregation period, whether in time or trades or range. I am unsure that ToS will allow shorter aggregations on a longer chart (no access to 1m data on 5m chart), but the other way works (5m data on 1m chart). I believe what you're looking for is in a similar boat.That code shows that difference but it doesn't update until current bar close...
How can we GetTime() difference between current and last bar in 'real time'?
I am aware of being able to do something like declare once_per_bar; but I am unaware of any such declaration to make it constantly update. My guess is that there isn't really a way for us to do that through ToS. I may very well be mistaken, but I'm not sure that what you're after can be done. Most of ToS (and any trading thing for that matter) is built on the idea of a block of some aggregation period, whether in time or trades or range. I am unsure that ToS will allow shorter aggregations on a longer chart (no access to 1m data on 5m chart), but the other way works (5m data on 1m chart). I believe what you're looking for is in a similar boat.
Not the answer you wanted, but we work with what we have
Happy Trading,
mashume
You can, btw, also find me on Discord -- both in the UseThinkScript channels and the B4 channels.@mashume - Completely non-contextual, but just wanted to find a way to msg you to tell you that everything you've created is gold. Pure gold.
Thank you
One option for you:
This one is really raw, and gives you the time delta since the last candle.
Code:declare lower; def t = getTime(); plot delta_t = t - t[1];
hope that helps
Happy Trading,
-mashume
Perhaps...agree with @maxtrader , @mashume code below is brilliant in its sheer simplicity! highly useful.
say, on a side note, speaking of tickcharts - is there a way to set an alert on ToS to sound off when a tickchart candle completes?
Alert(OPEN >= 0 , Alert.BAR, Sound.Ding);
oops, sorry about that.. did my image not appear correctly?@Ronin13 Please refer to the How to insert image in a post thread? topic...
oops, sorry about that.. did my image not appear correctly?
Does this work for you? I'm using bar chart and it always showThanks Mashume!
60,000
. Nothing in real time. Just like you, I really want to access elapsed time on current candle. Please share the code if you can. Much appreciate it. Thanks!Start a new thread and receive assistance from our community.
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.
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.