ThinkorSwim Bid Ask Volume (BAVOL) Indicator

Status
Not open for further replies.

mashume

Expert
VIP
Lifetime
I've been hacking together thinkscript studies for a while and have come across the idea of trying to see the buy/sell pressure with the difference in bid and ask volumes.

Code:
declare lower;
def askVol = Volume(priceType = PriceType.ASK);
def bidVol = Volume(priceType = PriceType.BID);
plot pressure = askVol - bidVol;

but while it is legal code according to thinkorswim, it doesn't seem to produce any results. At all.

I'm trying to run this against tick charts, not time aggregated.

I found a study that uses this (mobius' perhaps):

Code:
def TradeCountASK = tick_count(priceType = PriceType.ASK);
def TradeCountBID = tick_count(priceType = PriceType.BID);

And does something on time-based charts, but doesn't do anything (seemingly) on tick-based charts. Any help would be sincerely appreciated.
 
Solution
Does this come close to what you're interested in? You can remove the first label if you want as it's really there as a sanity check for me.

Code:
####################
#
# Ticks Per Minute for Time Charts
#
# Mashume via UseThinkScript
# 2020-08-17
#
####################
declare lower;
declare zerobase;

def timeframe = getAggregationPeriod() / 60000;

addLabel(yes, concat("Min / Bar: ", timeframe));

def T = Tick_count;

plot TicksPerMinute =  T / Timeframe;

addLabel(yes, concat("Ticks / Min: ", TicksPerMinute), color.gray);

-mashume

Also, potentially of interest is this one, which plots a histogram of the average size of trades in a candle. It can be interesting to see when large orders come in...

Code:
####################
#
#...

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

I am very interested in this too, I found this thread where @mashume tried something for tick charts but i havn`t seen anything working for time based charts. If anyone has a working BAVOL script for time charts, please share.
 
I think you have to declare a period of time other wise doesn't work try this:

You can change the agregation period to any time frame just do it in this format AggregationPeriod.MIN, AggregationPeriod.TWO_MIN, AggregationPeriod.THREE_MIN.

Code:
def ASK = tick_count(priceType = PriceType.ASK , period =AggregationPeriod.FIFTEEN_MIN);
def BID = tick_count(priceType = PriceType.BID , period =AggregationPeriod.FIFTEEN_MIN);
plot ba= ASK-BID;
 
Last edited:
Nope. I would be very interested in this if you could find the solution, I've been trading M and NIO on tick charts and want any edge I can get.
Also @mashume is there a way to get a plot of ticks per minute as a lower indicator? I feel like I could find that useful also as a way to gauge increased activity. A formula for that could be something along the lines of (last 10 min/ total ticks in last 10 min) or any choice of time. Hopefully it is possible.
 
Does this come close to what you're interested in? You can remove the first label if you want as it's really there as a sanity check for me.

Code:
####################
#
# Ticks Per Minute for Time Charts
#
# Mashume via UseThinkScript
# 2020-08-17
#
####################
declare lower;
declare zerobase;

def timeframe = getAggregationPeriod() / 60000;

addLabel(yes, concat("Min / Bar: ", timeframe));

def T = Tick_count;

plot TicksPerMinute =  T / Timeframe;

addLabel(yes, concat("Ticks / Min: ", TicksPerMinute), color.gray);

-mashume

Also, potentially of interest is this one, which plots a histogram of the average size of trades in a candle. It can be interesting to see when large orders come in...

Code:
####################
#
# Volume By Tick
#
# Mashume via UseThinkScript
# 2020-08-17
#
####################
declare lower;

def V = volume;
def T = Tick_count;

def tvb = (close - low) + (close - open) - (high - close);

def sign = if HL2 + tvb > HL2 then 1 else -1;

plot VolumePerTick = sign * V / T;
VolumePerTick.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
VolumePerTick.AssignValueColor(if VolumePerTick > 0 then Color.DARK_GREEN else Color.DARK_RED);
 
Solution
@mashume Very great stuff, looks good. Thanks as usual. I didn't check them yet but I'll report back to see if they work or are useful.

The ticks per minute one doesn't work, I think it could be a great combo indicator though if you find out how. (Ticks per minute * Trade size per tick) = Idea of when the big boys are buying.

Correction, first one doesn't work on tick charts
 
@mashume this worked for me but I have an issue, how could the bars have a greater width? the bars with this code are tiny.

Good evening, why is the Level 2 Delay for 8 hours when programmed to be access with a Live Realtime data account.

Here is the code:

Code:
def ASK = tick_count(priceType = PriceType.ASK , period = AggregationPeriod.FIFTEEN_MIN);
def BID = tick_count(priceType = PriceType.BID , period = AggregationPeriod.FIFTEEN_MIN);
#plot ba= ASK-BID;
plot a = ASK;
a.SetLineWeight(1);
plot b = BID;
b.SetLineWeight(1);
 
@mashume this worked for me but I have an issue, how could the bars have a greater width? the bars with this code are tiny.

Good evening, why is the Level 2 Delay for 8 hours when programmed to be access with a Live Realtime data account.

Here is the code:

Code:
def ASK = tick_count(priceType = PriceType.ASK , period = AggregationPeriod.FIFTEEN_MIN);
def BID = tick_count(priceType = PriceType.BID , period = AggregationPeriod.FIFTEEN_MIN);
#plot ba= ASK-BID;
plot a = ASK;
a.SetLineWeight(1);
plot b = BID;
b.SetLineWeight(1);
If you haven't figured this out yet, you can try setting the LineWeight to 5. It takes an integer in the range of 1 to 5 with 5 being the widest.

-mashume
 
Ruby:
declare lower;
declare zerobase;

def A = A[1] + close;
def B = B[1] + close;


input length = 50;
plot Vol = volume;
plot VolAvg = Average(volume, length);

Vol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Vol.SetLineWeight(3);
Vol.DefineColor("Up", Color.UPTICK);
Vol.DefineColor("Down", Color.DOWNTICK);

Vol.AssignValueColor(if close > close[1] then Vol.color("Up") else if close < close[1] then Vol.color("Down") else GetColor(1));
VolAvg.SetDefaultColor(GetColor(8));

############
def countUP = if !IsNaN(A)
then 1
else if CLOSE > CLOSE[1]
then countUP[1] + 1
else if !IsNaN(B)
then 0
else countUP[1];

#TRYING TO ADD UP THE VOLUME FOR BUYERS AND SELLERS USING UPTICK OR DOWNTICK NEED HELP THANKS !!!
###############################

ADDLABEL(YES,"BUYERS "+ COUNTUP);

#ADDLABEL(YES,"BUYERS "+ COUNTUP,COLOR.GREEN);
#ADDLABEL(YES,"SELLERS "+ COUNTDN,COLOR.RED);
AddLabel(yes, "SELLERS:" + Vol[1]);
AddLabel(yes, "BUYERS:" + Vol);
 
Last edited by a moderator:
Ruby:
declare lower;
declare zerobase;

def A = A[1] + close;
def B = B[1] + close;


input length = 50;
plot Vol = volume;
plot VolAvg = Average(volume, length);

Vol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
Vol.SetLineWeight(3);
Vol.DefineColor("Up", Color.UPTICK);
Vol.DefineColor("Down", Color.DOWNTICK);

Vol.AssignValueColor(if close > close[1] then Vol.color("Up") else if close < close[1] then Vol.color("Down") else GetColor(1));
VolAvg.SetDefaultColor(GetColor(8));

############
def countUP = if !IsNaN(A)
then 1
else if CLOSE > CLOSE[1]
then countUP[1] + 1
else if !IsNaN(B)
then 0
else countUP[1];

#TRYING TO ADD UP THE VOLUME FOR BUYERS AND SELLERS USING UPTICK OR DOWNTICK NEED HELP THANKS !!!
###############################

ADDLABEL(YES,"BUYERS "+ COUNTUP);

#ADDLABEL(YES,"BUYERS "+ COUNTUP,COLOR.GREEN);
#ADDLABEL(YES,"SELLERS "+ COUNTDN,COLOR.RED);
AddLabel(yes, "SELLERS:" + Vol[1]);
AddLabel(yes, "BUYERS:" + Vol);
This thread should have what you are looking for. Should be tick_count.

https://usethinkscript.com/threads/thinkorswim-bid-ask-volume-bavol-indicator.1542/

Another example of tick_count against alternate symbol.
https://tosindicators.com/indicators/cumulative-tick
 
I've been hacking together thinkscript studies for a while and have come across the idea of trying to see the buy/sell pressure with the difference in bid and ask volumes.

Code:
declare lower;
def askVol = Volume(priceType = PriceType.ASK);
def bidVol = Volume(priceType = PriceType.BID);
plot pressure = askVol - bidVol;

but while it is legal code according to thinkorswim, it doesn't seem to produce any results. At all.

I'm trying to run this against tick charts, not time aggregated.

I found a study that uses this (mobius' perhaps):

Code:
def TradeCountASK = tick_count(priceType = PriceType.ASK);
def TradeCountBID = tick_count(priceType = PriceType.BID);

And does something on time-based charts, but doesn't do anything (seemingly) on tick-based charts. Any help would be sincerely appreciated.
I've been messing around with tick_count for a while. This produces meaningful results. Check it out. Maybe you can improve.
https://usethinkscript.com/threads/bid-ask-volume-bavol-indicator-for-thinkorswim.10515/
 
Last edited by a moderator:
Status
Not open for further replies.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
337 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