How to include premarket data in my watchlist column


Category:
0
0

def today = volume(period = “DAY”)

 

This is a line of code I have in one of the chart indicators and it works fine for showing the volume for the day. However, can I modify this line of code to include the premarket volume also in the total.

Premarket volume 7am-9:29est+volume of the day from 9:30est till……..

Marked as spam
Posted by (Questions: 22, Answers: 63)
Asked on May 7, 2018 6:46 pm
452 views
0
Private answer

One thing we need to state clearly from the start is that when you specify pre-market data you are expressly omitting the previous days after-market data. Which means this is very different than “extended hours” data. Because we are only going to capture the pre-market section of the extended hours data.

I see that your code uses a secondary aggregation period of “DAY”. This is not supported in custom columns. The time frame for a custom column is determined by a setting at the very top of the Custom Quote Formula window. And in your case, you will need to set that to an intraday time frame. Something like 15 minute would be ideal.

Why? Because you can only reference extended hours chart data from the intraday time frame. Impossible to do it from the daily or higher time frame.

So we have that clear. Here is the code:

def newDay = GetDay() <> GetDay()[1];
rec todaysVolume = if newDay then volume else todaysVolume[1] + volume;
plot data = todaysVolume;

Two screenshots below. One shows the custom quote formula is set to 15 min. (notice the “Include EXT” box is checked!!!). The other shows the result applied to a custom watchlist column.

Attachments:
Marked as spam
Posted by (Questions: 37, Answers: 4117)
Answered on May 7, 2018 7:28 pm
0
hi pete, awesome code as always, appreciate what you do! question: i cant get manage to make the "sort by" to work properly? thx!
( at March 11, 2024 3:57 pm)
0
You probably didn't notice that values greater than 10 million have been converted to scientific notation. When you account for that, you should find the sorting is working perfectly. Sorry but that scientific notation is something that Thinkorswim is doing on it's own. If you want to avoid that you can try dividing the final result by 1 million. But then you need to remember you did that, and that all of the values are listed in millions. So a value of 48.3 would actually be 48,300,000. Here is how you would modify the last line of code to do that: plot data = todaysVolume / 1000000;
( at March 11, 2024 5:32 pm)