Watchlist Columns for Pre-market Volume


Category:
0
0

Hi pete, 

I am trying to set up a custom column for my ThinkorSwim watchlist for pre-market volume.

However, I am running into some problems if there were no premarket activity for the stock today. Instead of showing 0, it shows prior day’s pre-market volume.

How do I get around this to show today’s information only?

Please find the code below, and thanks in advance for your help!

 

 

def isRollover = GetYYYYMMDD() != GetYYYYMMDD()[1];

def beforeStart = GetTime() < RegularTradingStart(GetYYYYMMDD());

def vol = if isRollover and beforeStart

          then volume

          else if beforeStart

               then vol[1] + volume

               else Double.NaN;

def PreMarketVol = if IsNaN(vol)

                   then PreMarketVol[1]

                   else vol;

 

plot PMV = PreMarketVol;

Marked as spam
Posted by (Questions: 1, Answers: 1)
Asked on March 15, 2020 1:16 am
1289 views
0
Private answer

Did you search the forum before posting? Because I searched for this and found only two posts, yours, and the one that was already posted:

https://www.hahn-tech.com/ans/how-to-include-premarket-data-in-my-watchlist-column/

Please let us know if you checked this first. If it didn't do what you are trying to accomplish be sure to explain exactly how that previous posts missed the mark you are trying to achieve.

Edit: There is already a solution that displays a chart label for total volume withing a specified time period. The code presented in the question posted here contains the code to set your start and end time for the volume calculation:

https://www.hahn-tech.com/ans/premarket-volume-labels-showing-less-volume-than-real/

Here I am included that code, modified very slightly to work as a custom watchlist column:

input startTime = 400;
input endTime = 929;
def startCounter = SecondsFromTime(startTime);
def endCounter = SecondsTillTime(endTime);
def targetPeriod = if startCounter >= 0 and endCounter >= 0 then 1 else 0;
rec volumeTotal = if targetPeriod and !targetPeriod[1] then volume else if targetPeriod then volumeTotal[1] + volume else volumeTotal[1];
AddLabel(yes, Concat("Target Period Volume: ", volumeTotal), Color.GRAY);

Please note that your custom column will need to be set to include extended hours session. You can set the start and end time to whatever span of time you need to cover. Remember that custom watchlist columns always use Eastern timezone.

Marked as spam
Posted by (Questions: 37, Answers: 4118)
Answered on March 15, 2020 7:44 am
0
Thanks Pete for your reply. Unfortunately, the link shows the the code for: Total daily volume including premarket volume, While I'm looking for: Just the premarket volume of today only. But my code fails when there was 0 premarket volume, and instead of showing this it shows premarket volume of the last premarket session when there was volume. I wanted to edit the original question to include a screenshot, but I'm having trouble doing so :( For example, my code shows Premarket volume = 100 for ticker ARES (which was from Thursday's pre-market session because Friday's pre-market session had 0 volume) Thanks in advance for your help!
( at March 15, 2020 10:36 am)
0
Please refer to this screenshot (https://pasteboard.co/IZeNR1G.png) for the issue: (cursor on Thursday's premarket showing volume = 100 (which feeds into the watchlist), because there was no premarket activity from Friday).
( at March 15, 2020 10:46 am)
0
Hi Pete, just following up with my question. Did you understand my issue?
( at March 16, 2020 10:36 am)
0
I have updated my answer to provide an exact solution to your request.
( at March 16, 2020 11:01 am)
0
Thanks Pete, Unfortunately it is still does not show premarket volume = 0 if there were no premarket actvity today. Instead showing the premarket volume of last trading day with premarket activity. Thank you anyway for your help.
( at March 16, 2020 3:04 pm)
0
There may be a way to apply some much more advanced code to accomplish what you are trying to achieve here. The code to handle this would need to check to see if any trades occurred during premarket hours. Then substitute a value of zero in place of the most recently available premarket trading data. This is far beyond the scope of something I can provide for no charge in the Q&A forum. If this feature is absolutely critical to your trading success I suggest you submit this as a custom project request.
( at March 16, 2020 3:30 pm)