Display time between bars in real time


Category:
0
0

Hey everyone! I made a post recently titled Display time between bars .  While it works great, there is a major error. The time between bars is only plotted if there is an actual trade at the current time. Let’s say we are on a 1 minute chart and there was a trade at 9:35 and the next trade was at 9:40 then the value for the previous would return 5 which is awesome. However, for what I need done I need the current time value (even if there is no trade on the chart) being compared to the time value of the last 1 minute candle. There’s just a small error with the previous script that I’m having a hard time fixing. Any ideas?

 

Thank you!

Marked as spam
Posted by (Questions: 8, Answers: 5)
Asked on August 18, 2020 8:12 pm
60 views
0
Private answer

Sorry but for Thinkorswim at least the only way to measure the time is between bars. So until the next bar begins trading there is simply nothing there for the code to measure.

The only suggestion I have is to use a ticker symbol for one of the Index ETF's on the price graph and then plot the close for whatever ticker symbol you are tracking on the lower subgraph. The number of minutes between gaps in the price cannot be measure directly but you will see how many bars are missed since the most recent trade.

This is extremely difficult to solve for you because you have not provided a list of stocks that routinely have gaps in their trade data. Most of us spend a great deal of time trying to remove these stocks from our scan results. But for some reason when we try to find some examples they are nearly impossible to find.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on August 19, 2020 8:38 am
0
I am using this study for options trading. Here's an example ticker: .BLNK200821P5 This ticker is pretty illiquid so there are time gaps in the charts. Is there any way possible to measure the time difference between the time when the last bar was plotted and the current time even if there isn't a bar?
( at August 20, 2020 6:57 am)
0
Thanks for providing a specific example to work with. There is no way to do what you have requested. The best you can achieve this on Thinkorswim is to plot a ticker symbol on the chart that does not contain gaps, then apply the following statement to a lower study applied to the chart: plot test = close(symbol = ".BLNK200821P5");
( at August 20, 2020 9:12 am)