Average Premarket Volume For ThinkOrSwim

flowtrader

New member
Hello I am trying to create a premarket average volume indicator. I have the premarket bubble but I need to be able to compare it to an average the easiest would be 30 day average.

plot Data = close;#PreMarket Volume
input startTime = 0400;
input endTime = 0929;
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("PreMarket Vol: ", volumeTotal), Color.VIOLET);

is there any way to make a 30 day premarket average bubble to go along with this? Thank you.

I am trying to get a "label" not a bubble I do not fully understand all of the terms yet. The most similar I have found on Thinkscript is from user name "Astroboy". The question was "% change in premarket volume from previous day". I have the code for premarket volume for the current day as posted above previously. The code was built upon in the "Astroboy" post to include the previous days premarket volume in a label next to the current days premarket volume label. My question is there any way to create 30 days of premarket average volume and put that in label form to include with the other labels on the chart. Think or swim has built in a 30 day average volume indicator but it is only for daily traded volume. It would be great to compare todays premarket volume with yesterdays premarket volume and a longer term 30 day average premarket volume along with them in label form. If any one has any ideas they are greatly appreciated thank you.
 
Last edited by a moderator:
input Start = 0400;
input End = 0929;
input ShowTodayOnly = yes;
def Today = if GetDay() == GetLastDay() then 1 else 0;

def VolumeFromStart = SecondsFromTime(Start) >= 0 and SecondsTillTime(End) > 0;
def VolumeAtEnd = SecondsFromTime(End) >= 0;
def VolumeRange = VolumeFromStart and !VolumeFromStart[1];
def VolumeInRange = if VolumeRange then volume else if VolumeFromStart then VolumeInRange[1] + volume else VolumeInRange[1];
def V = (VolumeAtEnd + VolumeInRange);
def Cumulativevolume = if VolumeFromStart then VolumeInRange else Cumulativevolume[1];

def PreviousDayPreMarketVolume = if ShowTodayOnly and !Today then Cumulativevolume[1] else PreviousDayPreMarketVolume[1];

plot PreMarketVolume = Cumulativevolume;

def PercentChange = (((V - PreviousDayPreMarketVolume) / PreviousDayPreMarketVolume)) * 100;

AddLabel(start, + round (PercentChange));
AssignBackgroundColor(

if PercentChange > 1000 then Color.plum else
if PercentChange > 100 then Color.dark_GREEN else
if PercentChange < 100 then Color.BLACK else
if PercentChange <= 0 then color.red else Color.Gray);

This is the code that I cut and pasted for myself for WATCHLIST COLUMN. It compares yesterday to today volume percentage difference it is the best I have found until someone can figure out the 30 day premarket volume average. Above 1000% and 100% the potential for a strong move is high you must have an edge in your trading just because volume is high this will not confirm direction of move you must anticipate which direction it will move.
 
The most useful code I've found so far is "time bracketed volume". I added lookback periods so it's comparing the last 10 pre-markets.


Code:
#StudyName: Time Bracketed Volume Average

#Description: Averages time bracketed volume

#Author: DMonkey

#Requested By:  Chat Room Discussion

# Ver  2   Date 7.4.2018 # Corrected typo in

# 

# Trading Notes:Averages the last TEN time brackets.  Intent is less is more.

#               Paints Histogram when higher than average volume is present during the time bracketed session.

##MB added lookback periods for 10 ma

#Declarations

declare lower;

declare hide_on_daily;

 

#inputs

input Day_Session_From_Open = 0600;

input Day_Session_End = 0930;

 

#calcs

def v = volume;

def na = double.nan;

 

def Is_Session_From_Open = SecondsFromTime(Day_Session_From_Open) >= 0

                        && SecondsTillTime(Day_Session_End) > 0;

 

def New_Session_From_Open = Is_Session_From_Open

                        && !Is_Session_From_Open[1];

def Cum_Vol = if New_Session_From_Open

              then v

                  else if Is_Session_From_Open

                  then Cum_Vol[1] + v

              else Cum_Vol[1];

 

def count = count[1] + if New_Session_From_Open

                       then 1

                       else 0;

 

def Session_Volume1;

def Session_Volume2;

def Session_Volume3;

def Session_Volume4;

def Session_Volume5;

def Session_Volume6;

def Session_Volume7;

def Session_Volume8;

def Session_Volume9;

def Session_Volume10;

 

if (New_Session_From_Open and count > 1) {

    Session_Volume1 = Cum_Vol[1];

    Session_Volume2 = Session_Volume1[1];#Corrected typo here

    Session_Volume3 = Session_Volume2[1];#Corrected Typo Here

    Session_Volume4 = Session_Volume3[1];#Corrected typo here
  
    Session_Volume5 = Session_Volume4[1];#Corrected typo here

    Session_Volume6 = Session_Volume5[1];#Corrected typo here

    Session_Volume7 = Session_Volume6[1];#Corrected Typo Here

    Session_Volume8 = Session_Volume7[1];#Corrected typo here
  
    Session_Volume9 = Session_Volume8[1];#Corrected typo here

    Session_Volume10 = Session_Volume9[1];#Corrected typo here

} else {

    Session_Volume1 = Session_Volume1[1];

    Session_Volume2 = Session_Volume2[1];

    Session_Volume3 = Session_Volume3[1];

    Session_Volume4 = Session_Volume4[1];

    Session_Volume5 = Session_Volume4[1];
 
    Session_Volume6 = Session_Volume5[1];#Corrected typo here

    Session_Volume7 = Session_Volume6[1];#Corrected Typo Here

    Session_Volume8 = Session_Volume7[1];#Corrected typo here
  
    Session_Volume9 = Session_Volume8[1];#Corrected typo here

    Session_Volume10 = Session_Volume9[1];#Corrected typo here

}

 

#Plots

plot Cumulative_Session_Volume = if Is_Session_From_Open

                                 then Cum_Vol

                                 else na;

 

plot Average_Session_Volume = if count > 10

                              then (Session_Volume1 +

                                    Session_Volume2 +

                                    Session_Volume3 +

                                    Session_Volume4 +

                                    Session_Volume5 +

                                    Session_Volume6 +

                                    Session_Volume7 +

                                    Session_Volume8 +

                                    Session_Volume9 +

                                    Session_Volume10 ) / 10

                              else na;

 

#Plot Management

Cumulative_Session_Volume.DefineColor("Below", CreateColor(102,102,255));

Cumulative_Session_Volume.DefineColor("Above", Color.Green);

Cumulative_Session_Volume.AssignValueColor(if Cumulative_Session_Volume > Average_Session_Volume

                                           then Cumulative_Session_Volume.Color("Above")

                                           else Cumulative_Session_Volume.color("Below"));

Cumulative_Session_Volume.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);

Average_Session_Volume.SetDefaultColor(Color.Gray);

Average_Session_Volume.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);





When I changed it to a watchlist / scan, it works OK, but I get nan on roughly half my tickers. I'm guessing they don't all have pre-mkt data to compare.

Code:
plot scan = (Cumulative_Session_Volume / Average_Session_Volume);
 
I got N/A for all stocks all top 10 spy names all N/A which they have premarket volume is there a specific setting for the column?
 
Ok, here's what I've come up with:

Code:
# 5-day Average Premarket Volume
declare upper;

########## Scripts
script BarsPerPeriod {
    input barCount = 32; #hint barCount: the number of 30 minute candles in a full trading day
    input length = 11; #hint length: the number of premarket candles to count
    plot cumulativeVolume = (fold i = 0 to length with o = 0 do o + GetValue(volume, (barCount - i), 0));
}

script PremarketVolume {
    # code for today's premarket volume
    def st = 0400; # today's premarket start time
    def et = 0929; # today's premarket end time
    def Active = SecondsFromTime(st) >= 0 and SecondsTillTime(et) >= 0;
    def tPV = if Active and !Active[1] then volume
              else if Active then (tPV[1] + volume)
              else tPV[1];
    plot TodaysPremarketVolume = tPV;
      
    # code for prior days' premarket volume
    input barCount = 32; #hint barCount: the number of 30 minute candles in a full trading day
    def pst = 0400; # prior days' premarket start time
    def pet = 0429; # prior days' premarket end time
    def pActive = SecondsFromTime(pst) >= 0 and SecondsTillTime(pet) >= 0;
    def pPV = if pActive and !pActive[1] then BarsPerPeriod(barCount).cumulativeVolume
              else if pActive Then pPV[1] + BarsPerPeriod(barCount).cumulativeVolume
              else pPV[1];
    plot PremarketVolume = pPV;
}
########## /Scripts

input showLabels = yes;

def day1 = PremarketVolume(32).PremarketVolume;
def day2 = PremarketVolume(64).PremarketVolume;
def day3 = PremarketVolume(96).PremarketVolume;
def day4 = PremarketVolume(128).PremarketVolume;
def day5 = PremarketVolume(160).PremarketVolume;

AddLabel(showLabels, "Day 1: " + day1, Color.Light_Gray);
AddLabel(showLabels, "Day 2: " + day2, Color.Light_Gray);
AddLabel(showLabels, "Day 3: " + day3, Color.Light_Gray);
AddLabel(showLabels, "Day 4: " + day4, Color.Light_Gray);
AddLabel(showLabels, "Day 5: " + day5, Color.Light_Gray);

def AvgPremarketVolume = Round((day1 + day2 + day3 + day4 + day5) / 5, 0); # tried to implement as a fold function but couldn't get it to work
def todaysPremarketVolume = PremarketVolume(0).TodaysPremarketVolume;
def Avg = Round((todaysPremarketVolume / AvgPremarketVolume) * 100, 0);

AddLabel(showLabels, "Avg PV: " + AvgPremarketVolume, Color.LIGHT_GRAY);
AddLabel(showLabels, "Today: " + todaysPremarketVolume + " | " + AsPercent(Avg / 100), Color.Orange);

Apply this on a 30min chart with extended hours on. It gets the premarket volume of the previous 5 days, averages that volume, and compares it with the current day's premarket volume. The labels for each of the 5 days are given just to show you what the numbers look like, but they can easily be commented out.

I used the 30min timeframe because it gives you the least amount of candles while accounting for the last 30 minutes of premarket volume (the hourly timeframes don't make it easy to get that data). This timeframe gives you a total of 32 candles from the start of premarket all the way to the end of after hours (11 premarket, 13 regular trading hours, 8 after hours). To get premarket data for the previous day:

1. Start with the first premarket candle of the current day
2. Count backwards 32 candles until you reach the first premarket candle of the previous day
3. Beginning with that first premarket candle, get the volume associated with it and move forward 1 candle until you've gone forward 11 candles, adding each candle's volume to the prior candle's volume. (Another way to look at it, you'll be counting down from 32 to 21.)

To get the same data for additional days, do the same steps listed above except in #2 multiply 32 by the number of days in the past you want. Of course, my code doesn't allow anything past 5 days, so you'll have to adjust it to suit your needs. Also, my code doesn't account for partial/short trading days or days in which a stock doesn't have 11 total premarket candles.

To ensure that the numbers are correct, you'll have to view a ticker and do some math by hand and compare the volume numbers you get with the numbers the labels show. My tests with TSLA show that I'm right, but take that with a half grain of salt.

My code is by no means perfect. Some of the code I don't fully understand as I reused code I've seen in other indicators to make this work. Hopefully someone can optimize it.

Hope this helps.
 
Last edited:
thank you for your code I will be testing it and I will let you know how it works out
This works better for me on the 5 min. I can see heavy premarket volume at lows and light premarket volume at highs and the reversals at both. It would be great if there was a way to extend it past 5 days for a bigger sample size but after a few weeks of data I will know the relative average for what I am trading. This compliments well the 2 day premarket volume I already use thank you very much for making it.
 
This works better for me on the 5 min. I can see heavy premarket volume at lows and light premarket volume at highs and the reversals at both. It would be great if there was a way to extend it past 5 days for a bigger sample size but after a few weeks of data I will know the relative average for what I am trading. This compliments well the 2 day premarket volume I already use thank you very much for making it.
Glad to see that you find value in this code.
 
I found a script on here:
https://usethinkscript.com/threads/pre-market-volume-for-thinkorswim.2383/page-2#post-86825
and modified it to show premarket volume sessions relative to the past 10 sessions and show as label



Ruby:
input Day_Session_From_Open = 0600;

input Day_Session_End = 0925;

def v = volume;
def na = Double.NaN;

def Is_Session_From_Open = SecondsFromTime(Day_Session_From_Open) >= 0

                        && SecondsTillTime(Day_Session_End) > 0;

 

def New_Session_From_Open = Is_Session_From_Open

                        && !Is_Session_From_Open[1];

def Cum_Vol = if New_Session_From_Open

              then v

                  else if Is_Session_From_Open

                  then Cum_Vol[1] + v

              else Cum_Vol[1];

 

def count = count[1] + if New_Session_From_Open

                       then 1

                       else 0;

 

def Session_Volume1;

def Session_Volume2;

def Session_Volume3;

def Session_Volume4;

def Session_Volume5;

def Session_Volume6;

def Session_Volume7;

def Session_Volume8;

def Session_Volume9;

def Session_Volume10;

 

if (New_Session_From_Open and count > 1) {

    Session_Volume1 = Cum_Vol[1];

    Session_Volume2 = Session_Volume1[1];#Corrected typo here

    Session_Volume3 = Session_Volume2[1];#Corrected Typo Here

    Session_Volume4 = Session_Volume3[1];#Corrected typo here
 
    Session_Volume5 = Session_Volume4[1];#Corrected typo here

    Session_Volume6 = Session_Volume5[1];#Corrected typo here

    Session_Volume7 = Session_Volume6[1];#Corrected Typo Here

    Session_Volume8 = Session_Volume7[1];#Corrected typo here
 
    Session_Volume9 = Session_Volume8[1];#Corrected typo here

    Session_Volume10 = Session_Volume9[1];#Corrected typo here

} else {

    Session_Volume1 = Session_Volume1[1];

    Session_Volume2 = Session_Volume2[1];

    Session_Volume3 = Session_Volume3[1];

    Session_Volume4 = Session_Volume4[1];

    Session_Volume5 = Session_Volume4[1];
 
    Session_Volume6 = Session_Volume5[1];#Corrected typo here

    Session_Volume7 = Session_Volume6[1];#Corrected Typo Here

    Session_Volume8 = Session_Volume7[1];#Corrected typo here
 
    Session_Volume9 = Session_Volume8[1];#Corrected typo here

    Session_Volume10 = Session_Volume9[1];#Corrected typo here

}

 



def avgs = (Session_Volume1 +

                                    Session_Volume2 +

                                    Session_Volume3 +

                                    Session_Volume4 +

                                    Session_Volume5 +

                                    Session_Volume6 +

                                    Session_Volume7 +

                                    Session_Volume8 +

                                    Session_Volume9 +

                                    Session_Volume10 ) / 10;

 def avg = Round(number = (cum_Vol / Avgs));


input showlabels = yes;

AddLabel(showLabels, "Avg PV: " + Avgs, Color.LIGHT_GRAY);
AddLabel(showLabels, "Today: " + cum_Vol + " | " + AsPercent(Avg), Color.Orange);
as label.
 
Last edited by a moderator:
Hello, I found this script works well in charts as a study, but when I want to import it as a scanner even just as filter, it showed me need to add more conditions otherwise I can't save it as filter, and when I want to import it as a watch list. It showed me, same as in scanner.

Can you make a scanner and watch list with share link? That would be incredibly helpful for someone like me don't know coding at all :)Thank you for your help!
 
Hello, I found this script works well in charts as a study, but when I want to import it as a scanner even just as filter, it showed me need to add more conditions otherwise I can't save it as filter, and when I want to import it as a watch list. It showed me, same as in scanner.

Can you make a scanner and watch list with share link? That would be incredibly helpful for someone like me don't know coding at all :)Thank you for your help!
I'm glad you're finding it helpful!! here is the link for the scanner http://tos.mx/QvwfAhe, I currently have it set to scan for a premarket volume greater than 300%, you can go into the script scroll down, and change it from 3 to whatever you like. and here is the watchlist http://tos.mx/8ndqEIR. Happy Trading!
 
I'm glad you're finding it helpful!! here is the link for the scanner http://tos.mx/QvwfAhe, I currently have it set to scan for a premarket volume greater than 300%, you can go into the script scroll down, and change it from 3 to whatever you like. and here is the watchlist http://tos.mx/8ndqEIR. Happy Trading!
Thank you for your help again).I tried this script two days,still have some issues with me.Hope you can explain to me or help understand it well.

1.It seems scanner will also find some stocks with 0 volume premarket, how can I remove those 0 stocks from result?


2. Also, this script seems not display the label in my watch-list,I tried two days, result didn't change.I don't it's my setting wrong or something else.

3.first day I met a strange problem, one stock only have 100 premarket volume, but label shown me that 14999% greater than before. I forgot to make a screenshot about this point, but I just want to know it's only happened in my laptop or others also met this.
 
Last edited by a moderator:
Thank you for your help again).I tried this script two days,still have some issues with me.Hope you can explain to me or help understand it well.

1.It seems scanner will also find some stocks with 0 volume premarket, how can I remove those 0 stocks from result?
BP7j4nu1_1L41_sG_AFhuSqqC1dLZAuQae8zHTTsq5CtOi18GSFJdQKYhE6l8xa-UXeLSLyAvFjfkWbNuY-Pu1iQGVaaodTH2pileiKx0n4H94TauaF0ngTkfes3Rx_gmSDc5PWqBZtZNPMmQzOOFexU-Zr9BXwnYsHMGBbCRIKvyiTPU7mOCi00EAv2cDYRQGDgfIv8AH00SZWj_fAWTJm4VYH0887IP2iUF6K6ZzfbusmxemYtLb3nTQjnm24JmyIAkiGie-H3DcY0m8f0OxfGVf12Q3eRUE7aiX1Kuubb_t6By-VU-1mNGTGXtC8bpJkxzHgHbBgaZ8YVzbFDi8p8zunLpUOtCGQfW6YAQCCWucUBwcJguIYNngu7bnT69vjssY7_psNlHrmn0etnhPAbepy2TBYYBwUPgAbkMP2b4jDihHqem0QVfQ5OLMHTEAUcTg0gfGbQzR1w9FHXvilwwKJca2ioeX_PEl-uO28QWuOW9EpKwuCRZulCxjQODVVvEaO_JxuPrsP37n9xF86P4-ZsFo7b9GsYPk1s-iF-CX6x42RIhqkp9R_S6nUp17BzFSLbHTfKTqg0On16kg9pkaaY3GaAEfCLHXIJtBHWMTH8-LuL0h6i49GeIBo5VZlKV63xbxjF4XkrwdY21ZYuuxGuJW36q_Reoa-_PBUZK7FrhycA9JrVEJXyqy5LhIm6y1DKExxle3aZxAsXwg4=w3235-h1538-no


2. Also, this script seems not display the label in my watch-list,I tried two days, result didn't change.I don't it's my setting wrong or something else.
nFL9pllp1B6IQag0DRBZQDJhd1Y7mHQzHFKg-FRhRtA9CS0VekVwnKfV8k1hkqjnI2atJO61Z-DulWOOImpuGFCPrC6rkmxTqskhxUWE9274u1V6teRNyBvnfdGQ6iR-xrJ1dGEnicm80cHI3IvFVjJvpI68WFmyP8VaWNvm9SHtI2HBZ-Z38LiXPRiL1gjzKyKf-dK3f831IAk0h2vRRRTR0XWff-GcvYQxO5BSOwKMB_fLyXrvUP980koQI07L3ggL3f7KcAls87rZfFrI1XycODWP0d9Vbucb1UGjiei5bSNXKWL3j2p0aDdO5pn2cJM_LMBbcobFckZZASpeEXaJXuY3gbtaTWUVluWjbNVaB02frLjiulsW1Hq6obSOwakFzJHS-ffA0n8EW7Cq_ZUKR-H1zZkW3NYOrEVr1t8JXxgLU6uzCn-Hgiwsk6pEviiYssUR2zZV3U9N-MdHRCjc38OzXHljane9WohUf3xAsw9uFNdoCzuLDgwEE7N5hFFyf2h4ANTL7GJXwI2j8fHmHile7sV8qhfs__pEwU0WjyjjdyCeNzRypH02VnTbKngnSDfk5hTtfRcPm1ObrGKt67jteADLAM3Bh10MzuY7ZO8wXbymy4Re06QM7DCY7121JT_QRKB8c0kjcnXV-bIcbtjw-7Z8MWjzBBstjVgrBzzzzMghCD0E5AUtnUxP2rIvopjgWbpOxlYGM-GTDNo=w412-h585-no

3.first day I met a strange problem, one stock only have 100 premarket volume, but label shown me that 14999% greater than before. I forgot to make a screenshot about this point, but I just want to know it's only happened in my laptop or others also met this.
I cant see those images, one thing I recommend is first make sure your scanner includes this: "plot scan = avg >=3 and avgs> 10000" this makes sure the average volume is 10,000. second its always best to run these on a custom watchlist. as for your labels on your watchlist, I cant see the images to tell you what the issue is.
 
I cant see those images, one thing I recommend is first make sure your scanner includes this: "plot scan = avg >=3 and avgs> 10000" this makes sure the average volume is 10,000. second its always best to run these on a custom watchlist. as for your labels on your watchlist, I cant see the images to tell you what the issue is.

1. First, I can sure your script works well in my charts, but just can't show its label in my customer watch list.

l2PwqgL.png


2i71Bbc.png


2. I checked again my scanner includes plot scan = avg >=3 and avgs> 10000,but still show result with 0 volume to me,I just don't understand this.

Rf873Y5.png


Lozfois.png


again, thank you made this amazing script, I just I can understand it well while using it.)
 
Last edited by a moderator:
1. First, I can sure your script works well in my charts, but just can't show its label in my customer watch list.

l2PwqgL.png


2i71Bbc.png


2. I checked again my scanner includes plot scan = avg >=3 and avgs> 10000,but still show result with 0 volume to me,I just don't understand this.

Rf873Y5.png


Lozfois.png


again, thank you made this amazing script, I just I can understand it well while using it.)
Okay I think Ik why the watchlist might not work , do you have set to 30 minute period aggregation? You may need to try 5 minutes if not. As for pv of zero , I honestly have no idea how to fix that , only thing I can perhaps suggest is try avgs[1] instead of “avgs” that should give you the average from the day before to compare against instead of today’s average. Let me know if that helps other than that, I have no idea how to fix it
 
Okay I think Ik why the watchlist might not work , do you have set to 30 minute period aggregation? You may need to try 5 minutes if not. As for pv of zero , I honestly have no idea how to fix that , only thing I can perhaps suggest is try avgs[1] instead of “avgs” that should give you the average from the day before to compare against instead of today’s average. Let me know if that helps other than that, I have no idea how to fix it
Well, thank you for your suggestions. About watch list, I will try to set different time frame to check if it will change or not.

As for PV of zero in scanner, honestly I probably won't change anything about code anymore(just I don't have much knowledge about code), at least now this scanner works fine, just have some unreal signal on result, I can remove it from my hand, it's not a big deal.

In total, I still think this is a great script, because I have never seen premarket volume of one stock in 10 days on any other platform, and it almost works perfectly as study in chart, thank you for your great work:)
 
I found a script on here:
https://usethinkscript.com/threads/pre-market-volume-for-thinkorswim.2383/page-2#post-86825
and modified it to show premarket volume sessions relative to the past 10 sessions and show as label



Ruby:
input Day_Session_From_Open = 0600;

input Day_Session_End = 0925;

def v = volume;
def na = Double.NaN;

def Is_Session_From_Open = SecondsFromTime(Day_Session_From_Open) >= 0

                        && SecondsTillTime(Day_Session_End) > 0;

 

def New_Session_From_Open = Is_Session_From_Open

                        && !Is_Session_From_Open[1];

def Cum_Vol = if New_Session_From_Open

              then v

                  else if Is_Session_From_Open

                  then Cum_Vol[1] + v

              else Cum_Vol[1];

 

def count = count[1] + if New_Session_From_Open

                       then 1

                       else 0;

 

def Session_Volume1;

def Session_Volume2;

def Session_Volume3;

def Session_Volume4;

def Session_Volume5;

def Session_Volume6;

def Session_Volume7;

def Session_Volume8;

def Session_Volume9;

def Session_Volume10;

 

if (New_Session_From_Open and count > 1) {

    Session_Volume1 = Cum_Vol[1];

    Session_Volume2 = Session_Volume1[1];#Corrected typo here

    Session_Volume3 = Session_Volume2[1];#Corrected Typo Here

    Session_Volume4 = Session_Volume3[1];#Corrected typo here
 
    Session_Volume5 = Session_Volume4[1];#Corrected typo here

    Session_Volume6 = Session_Volume5[1];#Corrected typo here

    Session_Volume7 = Session_Volume6[1];#Corrected Typo Here

    Session_Volume8 = Session_Volume7[1];#Corrected typo here
 
    Session_Volume9 = Session_Volume8[1];#Corrected typo here

    Session_Volume10 = Session_Volume9[1];#Corrected typo here

} else {

    Session_Volume1 = Session_Volume1[1];

    Session_Volume2 = Session_Volume2[1];

    Session_Volume3 = Session_Volume3[1];

    Session_Volume4 = Session_Volume4[1];

    Session_Volume5 = Session_Volume4[1];
 
    Session_Volume6 = Session_Volume5[1];#Corrected typo here

    Session_Volume7 = Session_Volume6[1];#Corrected Typo Here

    Session_Volume8 = Session_Volume7[1];#Corrected typo here
 
    Session_Volume9 = Session_Volume8[1];#Corrected typo here

    Session_Volume10 = Session_Volume9[1];#Corrected typo here

}

 



def avgs = (Session_Volume1 +

                                    Session_Volume2 +

                                    Session_Volume3 +

                                    Session_Volume4 +

                                    Session_Volume5 +

                                    Session_Volume6 +

                                    Session_Volume7 +

                                    Session_Volume8 +

                                    Session_Volume9 +

                                    Session_Volume10 ) / 10;

 def avg = Round(number = (cum_Vol / Avgs));


input showlabels = yes;

AddLabel(showLabels, "Avg PV: " + Avgs, Color.LIGHT_GRAY);
AddLabel(showLabels, "Today: " + cum_Vol + " | " + AsPercent(Avg), Color.Orange);
as label.
Hi,
I was playing around to calculate the pre market volume and found your script. Thanks for sharing.
Quick question: Shouldn't we have "0400" and "0929" in below two lines of your script to denote pre market opening and close.

input Day_Session_From_Open = 0600;
input Day_Session_End = 0925;
 
Hi,
I was playing around to calculate the pre market volume and found your script. Thanks for sharing.
Quick question: Shouldn't we have "0400" and "0929" in below two lines of your script to denote pre market opening and close.

input Day_Session_From_Open = 0600;
input Day_Session_End = 0925;
Yeah you can choose whatever time I actually updated mine to 800-925. There can be spikes in the early mornings but that doesn’t necessarily mean there’s gonna be a strong move/a lot of volume at the open
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
335 Online
Create Post

Similar threads

Similar threads

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