Buying Pressure For Tick Charts

tatl

Member
i think you need to create a counter. i'm bad at coding. it would go something like this:

first define the last price:
def last = close(pricetype = PriceType.LAST);

begin counting BuyingVolume at 0 at the start of each new bar.

if last(0) was greater than last(1) , which means that price increased, add volume (0) to BuyingVolume.

just need someone to help me code this and do all the counting logic and stuff! not sure how
 
Solution
hope that helps.
-mashume
hi mashume thank you for your reply. i've written a genuine buy/sell/neutral volume indicator for use on the 1-tick chart that i'd love you to take a look at and possibly help me expand. i'm new to thinkscript and still learning but really want to expand this tool.

Code:
declare lower;
#--------------------
def last = close;
#this is just for conceptual clarity. on the 1-tick chart, the close is always the last.

#--------------------
#restrictive buying, selling, and neutral logic:

def buyingTrue = if last > last[1] then 1 else 0;
def sellingTrue = if last < last[1] then 1 else 0;
def neutralTrue = if last == last[1] then 1 else 0;

#--------------------
# buy/sell/neutral volume / plots

plot buyingVol = if buyingTrue == 1 then volume else 0;
buyingVol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
buyingvol.setdefaultcolor(color.GREEN);

plot sellingVol = if sellingTrue == 1 then volume else 0;
sellingVol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
sellingvol.setdefaultcolor(color.RED);

plot neutralVol = if neutralTrue == 1 then volume else 0;
neutralVol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
neutralvol.setdefaultcolor(color.GRAY);

the basic idea is that if the last trade raised the last price at all, it's volume is counted as buying. if the last trade lowered the last price, it's volume is counted as selling, and if the last trade didn't move the last price, it's volume is counted as neutral.

what i want to be able to do is use this as a 1-tick chart indicator but aggregate the data for higher timeframes. want to be able to see the buy/sell/neutral vol for every one minute, every 5 minutes, etc. or higher tick aggregations. i'm trying to work with counting and resetting counts etc so i can aggregate the ticks into bigger bars but i'm having a hard time finding the right way to learn.

this fellow seems to have had success using 1-tick data to do all kinds of things...so i hope what i want is possible.
 
One-Tick charts... yikes. I once changed my display to /ES when I had had something on 50 ticks and the platform could hardly keep up. Single ticks is crazy (depending on your symbol I suppose).

The only way you can do aggregations on tick charts (you can't use secondary aggregation periods) is to use the clock and break between blocks:
Code:
declare upper;

input time_interval = 10;
def x = (getTime() % (60 * time_interval * 1000));
def boundary = if x < x[1] then 1 else 0;
addVerticalLine( boundary == 1, time_interval, color.black);

Where I have a vertical line when boundary == 1, you could reset your counter rather than draw the line.
You can also use the boundary and vertical line like this (which shows a bar count since the previous vertical line:
Code:
def c = if boundary[1] == 1 then 1 else c[1] + 1;
addVerticalLine( boundary == 1, " " + c, color.black);
Which was the original request this code came from (though I can't find it here on UTS at the moment or I would have simply linked it).

Note that while you can put all of this in a label as well, you could not put a secondary aggregation (tick or otherwise) on a tick chart (i.e. you cannot have a label base on 1 tick on a 100 tick chart -- ToS never allows you to have a lower period agg used in an indicator on a higher agg chart). You could, I suppose, have a chart in the flexible grid that had no 'upper' displaying price candles but only had the chart of pressure and hope that ToS can keep up if it's only displaying a single line at 1-tick.

-mashume
 
excellent i will look over this all. i wont be able to comprehend it until i study it.

just wanted to reply quickly- using flexible grid with no "upper" was exactly my plan (unchecking "show price subgraph" in settings). and combining it with another chart.

i was hoping there'd be a way to make the 1-tick histogram volume bars print less often. like, combine them into 1-minute bars for example. or like a 610 tick bar. have you ever seen this done?

Where I have a vertical line when boundary == 1, you could reset your counter rather than draw the line.
for the record i dont even know how to instruct my counter to reset. my skills are very rudimentary.
 
Last edited:
hi mashume thank you for your reply. i've written a genuine buy/sell/neutral volume indicator for use on the 1-tick chart that i'd love you to take a look at and possibly help me expand. i'm new to thinkscript and still learning but really want to expand this tool.

Code:
declare lower;
#--------------------
def last = close;
#this is just for conceptual clarity. on the 1-tick chart, the close is always the last.

#--------------------
#restrictive buying, selling, and neutral logic:

def buyingTrue = if last > last[1] then 1 else 0;
def sellingTrue = if last < last[1] then 1 else 0;
def neutralTrue = if last == last[1] then 1 else 0;

#--------------------
# buy/sell/neutral volume / plots

plot buyingVol = if buyingTrue == 1 then volume else 0;
buyingVol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
buyingvol.setdefaultcolor(color.GREEN);

plot sellingVol = if sellingTrue == 1 then volume else 0;
sellingVol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
sellingvol.setdefaultcolor(color.RED);

plot neutralVol = if neutralTrue == 1 then volume else 0;
neutralVol.SetPaintingStrategy(PaintingStrategy.HISTOGRAM);
neutralvol.setdefaultcolor(color.GRAY);

the basic idea is that if the last trade raised the last price at all, it's volume is counted as buying. if the last trade lowered the last price, it's volume is counted as selling, and if the last trade didn't move the last price, it's volume is counted as neutral.

what i want to be able to do is use this as a 1-tick chart indicator but aggregate the data for higher timeframes. want to be able to see the buy/sell/neutral vol for every one minute, every 5 minutes, etc. or higher tick aggregations. i'm trying to work with counting and resetting counts etc so i can aggregate the ticks into bigger bars but i'm having a hard time finding the right way to learn.

this fellow seems to have had success using 1-tick data to do all kinds of things...so i hope what i want is possible.

First, I Viewed the video on this Tread. The person created this Video is a very talented coder taking TOS to the limit. At this point, I am overwhelmed, but will be scratching at the surface to try to extract the essence of what he has done. Second, I was fascinated by the demonstration video above. It is dynamic and engaged in assessing order flow in a unique manner. TOS is an earlier platform that Mashume pts out , was not designed to provide real time calculations . As he so aptly puts it " there is no start of a bar". Recently I was directed to other Brokerage sites besides ThinkorSwim that offer additional options to view Cumulative Volume Delta (Bid/Ask) spreads as they unfold in histograms across a chart.- which what I consider real time Price Discovery I do not want to tease anyone, but I do know that even the original designers of TOS are a bit taken back by C. Schwabb purchase of TOS platform and are moving on to other platforms. I am a subscriber at TheoTrade.com and find their resources and suggestions helpful. We all want to learn and go forward. Best to all. To be sure, I am open to all suggestions regards what I call Price Discovery- which I prefer over Order Flow. As I understand it ( it is confusing)Order flow allows for Spoofing as Bid/Asks that are posted but not executed are not of any interest to me. I want executed trade flow only . :)
 

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
424 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