Custom Thinkscript - Volume Stats for ThinkOrSwim

jngy2k

jngy2k

Member
VIP
@SuryaKiranC i search tradingview screener for todays premarket volume and compared to the volume indicator premark vol are incorrect.
the code gives 1 million more volume for some stocks. then i backtested on tos and found the 1sthour vol started adding up before market opened at 930.
 
S

SuryaKiranC

Member
@jngy2k Ok, I have always had this debate with myself, but never extended to test this out on some low volume stock myself. so, for the part about Pre-Market and RTH1Hr, I think the fix should be 1 min before what is current default configured.

Code:
input PreendTime = 0929;
input RTH1HrendTime = 1029;

as for PostendTime, guess we don't have to worry about this since we stop trading at that sec anyways. After changing this I shifted through multiple timeframes and got the same results across timeframes. Will looking to the other issue as well. Please verify multiple tickers with PreMKt Volumes against TradingView.

Thanks for extensive testing.
-S
 
Last edited:
P

paraglohiya

New member
VIP
@jngy2k Here is the breakdown.

First Off all Buy/Sell Volume used to be a separate script with colored histogram on volume bars, I have added it to this one on request.
  • W/D Buy/Sell Volume Higher timeframe volumes, if you are on mins charts automatically shows Current days Buys/Sell Volumes and percentage. if you are on 1D charts shows 1W Buy/Sell Volumes and percentage. you need to enable this by setting "yes" for "show higher vol stats" ## Note Available from version 1.5.1 from next page only.
  • Buy/Sell volume always shows the % of Buy vs Sell on the current candle in any given timeframe. When the ticker is done trading they are not displaying any info, except for higher timeframes, 1D and above.
  • 30DAvg, This is self explained. Just incase 30 Days is what the script default and this is changeable, at script properties, no need to edit code. Incase, if somebody prefers a different length.
  • Day: is todays Volume, during the day along with Pre/Post market hours this will keep showing the day volume. And is "RED" till it cross 30D Avg, "LIME" on cross, "GREEN" on 150% of 30D Avg volume.
  • Day-1 - Day-4 are "Day minus 1" to "Day minus 4", basically last 4 days in the order the candles would appear on 1D charts, and are visible by default on 1D charts, Ex: 1Y 1D, 180 1D, or any other 1D time frames you may have configured, These are disabled by default on Lower Timeframes, but can be enabled as script properties if somebody prefers to see them on lower time frame charts, Ex: 1m, 5m, 15m or 1H.
  • Unlabeled White box next to "Day" is volume in % for someone who prefers, and is compared with 30D Avg, or defined Avg if someone has a custom length.
  • 30BarAvg, is again self explained, basically 30Bars on your timeframe, it is redundant when you are on a 1D chart. unless you have. As of now both Avg Days and number of Bars use the same input variable in script called "length" hence, if you change the property of the script and define length to 45 or 60, the AvgBar count would change too.
  • Both DayAvg and BarAvg labels are dynamic and represent the input value for "length". Should anybody were to change the length property it will display appropriate value in the label.
  • CurBar, is literally what it says, volume on current bar on your chart timeframe.
  • rVol, is Relative Volume basically used by some traders to gaze the % of volume in comparison to previous trading session. it's round value of (DayVol / 30Day Avg)
  • PreMktVol, is Pre-Market Volume of the day, starting at 4:00 AM EST.
  • RTH1HrVol, is Real Trade Hours 1st hour Volume.
  • PostMktVol, is after 4:00 PM EST Volume, till extended hours of trading is closed.
  • Pre/RTH1Hr/PostVol(s) are displayed only on lower timeframe charts, Ex: 1m, 5m, 15m, 1H or 4H.
Hope that helps. Following is are the list of improvement, I want to do, at sometime.
  • Want to be able to identify futures tickers and have a different time period definitions for Pre/Post Volume calculations as they trade differently.
  • Want to be able to compare the volume against the previous days same time frame of same time period of the previous day, to be able to make trade judgements. Ex: AAPL, 9:30AM - 11:30 AM is 20% volume of previous session, and today same time period is more 30%, We could anticipate it's possibly a hight volume day.
Let me know if you think I skipped any details.

**Note : Additional details added for newer version here instead of repeating this post.


Hi @SuryaKiranC - is there a way we can add these volume bars to the upper chart
Conditions -
1. Complete Red Candle (sell) - should print red arrow of size 3 or 5
2. if sell > buy 75% or 80% volume - should be of size 2 Red arrow
3. if sell ~ buy size like 49/51 or 51/49 % then the red arrow of size 1 if previous arrows were all red else if the previous arrow were green then green
4. if Green Candle (buy) - should print green arrow size of 3 or 5
5. if buy > sell 75% or 80% volume - should be of size 2 green arrow

thank you so much in advance!
 
P

paraglohiya

New member
VIP
@jngy2k here is the screenshot for your reference with 5D 5M chart.



this is awesome you guys rock. Please share the setup. the count for 1-13 is awesome. thank you again!
I am going to each page and lost at this as didn't knew where to get all this script. I am on 1.5.1 version right now
 
S

SuryaKiranC

Member
this is awesome you guys rock. Please share the setup. the count for 1-13 is awesome. thank you again!
I am going to each page and lost at this as didn't knew where to get all this script. I am on 1.5.1 version right now

Instead of re-posting the code everytime. I kept replacing the code https://usethinkscript.com/threads/custom-thinkscript-volume-stats-for-thinkorswim.970/post-33275, if your version reads 1.5.1 you are current. Only other change I have done and not posted is, put those volume labels in Millions to make it easy on the eyes. the 1-13 counter is a TOS default study called "SequenceCounter" nothing to do with my labels though.
 
S

SuryaKiranC

Member
Hi @SuryaKiranC - is there a way we can add these volume bars to the upper chart
Conditions -
1. Complete Red Candle (sell) - should print red arrow of size 3 or 5
2. if sell > buy 75% or 80% volume - should be of size 2 Red arrow
3. if sell ~ buy size like 49/51 or 51/49 % then the red arrow of size 1 if previous arrows were all red else if the previous arrow were green then green
4. if Green Candle (buy) - should print green arrow size of 3 or 5
5. if buy > sell 75% or 80% volume - should be of size 2 green arrow

thank you so much in advance!

Just the labels as upper study shouldn't be a big deal, but adding arrows or indicating using this data on any candle though would be lagging in my opinion. That would be another lagging indicator. There are many other methods and mechanisms to indicate Momentum.
 
P

paraglohiya

New member
VIP
Thank you @SuryaKiranC. My only challenge to identify if to identify pressure on either side. I tried looking into many indicator but none of these have that feature. this volume is the closest. I see another indicator which is called volume projection which is good but the graph is very complicated :) thank you again for quick response.
 
Rojo Grande

Rojo Grande

Member
VIP
Hello,
I would like to add two more colors to the label below, but am having trouble wrapping my head around it. I'm not a coder, I can do little basics but that's about it.

AddLabel(ShowSellVolumePercent, "Cur Bar Sell %: " + SellVolPercent, (if SellVolPercent > 85 then Color.RED else if SellVolPercent < 15 then Color.GREEN else Color.GRAY));

What I'm looking to do is when the percent is 70 to 84, the label would be yellow. 85 or above it would be red. Conversely, if the percent is between 30 to 16, the label is light blue, and 15 or lower it is green. Is this possible? Thank you.
 
S

SuryaKiranC

Member
@Rojo Grande

Try something like the below. I used your examples. Beware there is a gap between 30 - 70 % with no color assignment, either adjust the numbers or add one more condition.

AddLabel(ShowSellVolumePercent, "Cur Bar Sell %: " + SellVolPercent, (if SellVolPercent > 85 then Color.RED else if SellVolPercent <= 70 and SellVolPercent >74 then Color.Yellow else if SellVolPercent <30 and SellVolPercent >16 then Color.Light_Blue else Color.GRAY));
 
T

twitty_twit

New member
@SuryaKiranC

Is there any way to hide the "D buy" and "D sell" labels?

While I love this indicator, my eyes get so busy having all 4 "D buy/sell" and "buy/sell" labels next to one another. Thank you

 
Rojo Grande

Rojo Grande

Member
VIP
@Rojo Grande

Try something like the below. I used your examples. Beware there is a gap between 30 - 70 % with no color assignment, either adjust the numbers or add one more condition.

AddLabel(ShowSellVolumePercent, "Cur Bar Sell %: " + SellVolPercent, (if SellVolPercent > 85 then Color.RED else if SellVolPercent <= 70 and SellVolPercent >74 then Color.Yellow else if SellVolPercent <30 and SellVolPercent >16 then Color.Light_Blue else Color.GRAY));
Thank you. It gives me the following error.


Thank you. It gives me the following error
 
rad14733

rad14733

Well-known member
VIP
@Rojo Grande Replace LIGHT_BLUE with BLUE or CYAN... As the editor states, there is no LIGHT_BLUE color constant...
 
C

convertiblejay

New member
@jngy2k Did you figure out the code? i would love to know which one to use that depicts your picture or is there still an error?
 
S

SuryaKiranC

Member
@twitty_twit my bad for now watching the thread over the weekend. most of the labels are on and off, at script property levels. Look for "ShowHigherVolStats" and set this to no should turn them off on IntraDay charts.
 
Last edited:
S

SuryaKiranC

Member
@twitty_twit BTW, if the numbers are too much to process, you could easily convert those to Millions. the addition is " * .000001" in the formula and +"M" next to it in practically all labels that are related to Volumes or Price.


EX:
AddLabel(ShowTodayVolume, "Day: " + Round(Vol * .000001, 2) + " M ", (if PercentOfDayAvg >= UnusualVolumePercent then Color.GREEN else if PercentOfDayAvg >= 100 then Color.LIME else Color.RED));
 
Rojo Grande

Rojo Grande

Member
VIP
Is it also possible to plot sell percentage on this study?
Thank you.
 

Similar threads

Top