Bid Ask Volume (BAVOL) on tick-charts?

M

mashume

Active member
VIP
All,

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.
 
C

cesarword

New member
I think you have to declare a period of time other wise doesn't work try this:
you can change the agregation perios to any time frame just do it in this format AggregationPeriod.MIN, AggregationPeriod.TWO_MIN, AggregationPeriod.THREE_MIN
ETC...

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:
YungTraderFromMontana

YungTraderFromMontana

Well-known member
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.
 
C

cesarword

New member
Yes it doesn't work on tick chart because it has a time input. but it work on time chart. @YungTraderFromMontana It works with futures I don't know why not with equities probably not enough data.
 
YungTraderFromMontana

YungTraderFromMontana

Well-known member
yep you're right, maybe it can't keep up with equity volumes.
 
M

mashume

Active member
VIP
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);
 
YungTraderFromMontana

YungTraderFromMontana

Well-known member
@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
 
evanevans

evanevans

Member
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.
We just created this, it's been awesome for me (in day trading NIO, etc):
https://usethinkscript.com/threads/accessing-seconds-from-1min-chart.3516/page-2#post-33263

It helps predict if at the current moment, the volume represents what would be more or less volume than the previous minute by the end of the minute (before the end of the minute is up). I find it super helpful in seeing momentum order flow.
 
T

Tony Stark

New member
@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.
 
T

Tony Stark

New member
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:

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);
 

Similar threads

Top