Point and Figure Chart (PnF) in ThinkorSwim

Hey guys, please do you have an script that show price level of Point and Figure Charts in ThinkorSwim? I saw Point and figure (P&F) charts in stockcharts.com. Do we have some indicator similar to it? or near equivalent?
 
Last edited by a moderator:
Solution
@Johnny Cash Please go to the Tutorials and look in The Universe of Thinkscript. If it's been done, that would be the first place I would look. Once inside, use the search function, using both "Point" and "Figure" as key words. Don't give up too easy, sometimes you have to dig around in there!

13:00 Mobius: I went through the Market Profile phase, Point and Figure and several others some time ago when it was still new. Personally found no value in them. But I admit with my background what I use isn't appropriate for most.
@Johnny Cash Please go to the Tutorials and look in The Universe of Thinkscript. If it's been done, that would be the first place I would look. Once inside, use the search function, using both "Point" and "Figure" as key words. Don't give up too easy, sometimes you have to dig around in there!

13:00 Mobius: I went through the Market Profile phase, Point and Figure and several others some time ago when it was still new. Personally found no value in them. But I admit with my background what I use isn't appropriate for most.
 
Solution

BenTen's Watchlist + Setup + Trade Recaps

Get access to Ben's watchlist, swing trading strategy, ThinkorSwim setup, and trade examples.

Learn more

Back in the day, before the day, (early70's) I used to keep P&F charts by hand. Determining an instrument's price objective via the P&F count was old news back then, so you can imagine how "novel" that technique is today!
 
Point and Figure is about supply and demand. The best must book written on Point & Figure is by Thomas Dorsey. You can read Point and Figure Charting 2013.

I have read many books on P&F Thomas Dorsey is the best.
 
Last edited:
Hi guys, a while ago I entered this site, but I have never consulted anything. I am looking for some script on the Point and Figure tool, to install in TOS. Help me please?
 
I am trying to make vertical bars, like a custom candle. I can't find a good way to do this. One thought was to use horizontal plot lines and loop to make a solid box, but the problem is I can't find a way to do a loop + plot at the same time. I am wanting to make my own version of a P and F type chart that filters out market noise, mostly to try and identify markup, markdown, and accumulation/distribution channels. Probably based on some type of zigzag percent.

It seems possible because I noticed an indicator for sale that makes its own candle plots for a P and F chart as a reference https://funwiththinkscript.com/indicators/point-figure-chart/

How can I make bars like this guy did? Also, if this question can be answered, the followup question would be how can the data be aggregated so that there are not large gaps in between bars?

Any help would be greatly appreciated.

point_and_figure_6.png
 
My original goal wasn't to create a point and figure chart, but I think I got pretty close.

Code:
#Sid6.7
#Point and Figure Chart Lower Study

#this is a lower study
declare lower;

#debug mode to expand all of the bar to see how the reversals are calculated and at what point
#1 = debug mode
#0 = regular mode
def debug = 0;

#box size: change this to determine the size of a block
def boxsize = atr()/2;
#rev size: change this to determine the reversal size. this is just blocksize * revsize = reversal total
def revsize = 3;
def revtotal = revsize * boxsize;

#output a label to show our boxsize and reversal size
AddLabel(1, "B:" + boxsize + " R:" + revtotal);

#variables, not sure all of these are even used?
def center = ((high - low) / 2);
def isred = open > close;
def lowvalue = if isred then close else open;
def highvalue = if isred then open else close;
def lastbar = HighestAll(if IsNaN(close) then 0 else BarNumber());
def cbar = BarNumber();
def lastbaros = -(lastbar) + cbar;
def islastbar = IsNaN(close[-1]) and !IsNan(close);
def isfirstbar = IsNaN(close[1]) and !IsNaN(close);

#plots a future blue line at this close to help see then distance of the current price
def isfuture = if IsNaN(close) then 1 else 0;
def futureprice = if isfuture and IsNaN(futureprice[1]) then close[1] else if isfuture then futureprice[1] else Double.NaN;
plot f = futureprice;

########
## do per candle direction lookup and store box value location
########
def trendchanged;
rec dir;
#the value of our box = box_price
def block_price = round(close/boxsize, 0) * boxsize;
#the start point of our current trend
def block_price_start = if isnan(trendchanged[1]) then block_price
    else if trendchanged[1] then block_price
    else block_price_start[1];
#the highest box size we acheived in this trend
def block_trend_highest = if isnan(trendchanged[1]) then block_price
    else if trendchanged[1] then block_price
    else if block_trend_highest[1] < block_price then block_price
    else block_trend_highest[1];
#the lowest box size we acheived in this trend
def block_trend_lowest = if isnan(trendchanged[1]) then block_price
    else if trendchanged[1] then block_price
    else if block_trend_lowest[1] > block_price then block_price
    else block_trend_lowest[1];
#the direction of our trendchanged (i got this from https://futures.io/thinkorswim/5129-point-figure-tos-thinkorswim-trading-platform.html)
dir = if islastbar then dir[1] * -1 else compoundValue(1, if dir[1] == 1 and block_price <= block_trend_highest-revtotal then -1 else if dir[1] != 1 and block_price >= block_trend_lowest+revtotal then 1 else dir[1],1);
#was our trendchanged? if so the next candle will update our trend block values
trendchanged = dir != dir[1];
#this isn't used but could be useful for debug
def pnf_bar_count = if isnan(pnf_bar_count[1]) then 0 else if trendchanged then pnf_bar_count[1] + 1 else pnf_bar_count[1];

#get the total from the last bar
def total = getvalue(pnf_bar_count,lastbaros);
#some magical stuff that starts from then left to right side candle reading
#which does some future lookups
#to condense the p and f chart into the bars we need
def barnum;
def nextbar = if barnumber() == 1 then 1 else if barnum[1] == 0 then lastbar else barnum[1]+1;
barnum = if nextbar >= lastbar then 0 else fold i = nextbar to lastbar with b = 0
     while !isnan(getvalue(close,-i)) and b == 0
        do if getvalue(trendchanged,-i) and b == 0 then i else b;

#debug plots      
#if debug is enabled, we will mark where the trend changed, and the high/start/low points
AddChartBubble(trendchanged and debug, block_trend_lowest[1], dir[1]);
plot a1 = if trendchanged and debug then block_trend_highest[1] else double.nan;
a1.setdefaultColor(color.red);
a1.setpaintingStrategy(paintingStrategy.HORIZONTAL);
plot a2 = if trendchanged and debug then block_price_start[1] else double.nan;
a2.setdefaultColor(color.gray);
a2.setpaintingStrategy(paintingStrategy.HORIZONTAL);
plot a3 = if trendchanged and debug then block_trend_lowest[1] else double.nan;
a3.setdefaultColor(color.light_red);
a3.setpaintingStrategy(paintingStrategy.HORIZONTAL);
plot a4 = if debug then close else double.nan;

#after we do our magic above, we calculate how many plots we made, then we check the offset from the lastbar
#so we can move our chart from the leftside of the chart to the rightside of the chart
def charttotal = if barnum > 0 then (if isnan(charttotal[1]) then 0 else charttotal[1]) + 1 else charttotal[1];
#leftside and rightside here is technically, high and low, just for plotting our chart
def leftside = if debug == 1 then low else if barnum == 0 then double.nan else if getvalue(dir,-barnum) == 1 then getvalue(block_trend_lowest,-barnum) else getvalue(block_trend_highest,-barnum);
def rightside = if debug == 1 then high else if barnum == 0 then double.nan else if getvalue(dir,-barnum) == 1 then getvalue(block_trend_highest,-barnum) else getvalue(block_trend_lowest,-barnum);
#bar location we want to use, these are leftside bars, IE barnumber() == 1, 2, 3...to 'charttotal'
def barloc = if barnum == 0 and barnumber() + charttotal >= lastbar and barloc[1] == 0 then barnumber() else barloc[1];

#i got this from https://usethinkscript.com/threads/add-chart-as-a-lower-study.286/
#someone in then thinkscript trade chat lounge told me about the undocumented "addchart" method
DefineGlobalColor( "uptick", Color.UPTICK );
DefineGlobalColor( "downtick", Color.DOWNTICK );
#if we are debugging we will just output our high-low plots otherwise output pnf chart
#colors do not seem to work
def l = if debug then leftside else getvalue(leftside, barloc);
def r = if debug then rightside else getvalue(rightside, barloc);
AddChart( high = l,    
          close = l,
          low = r,  
          open = r,
          type = 2,
          growColor = GlobalColor( "uptick" ),
          fallColor = GlobalColor( "downtick" )
);

Edit: I made one change to the code, because the last bar was not showing. Also added the below image.

Also, so anyone that knows, to only show the PnF study, you would need to add a new chart below, and in the settings, disable show price subgraph, disable volume subgraph, extend 10 columns to the right, and then add the study to that, to show the way mine does.

ESGC 5year daily chart point and figure chart at the bottom
lwARxqO.png
 
Last edited:
@sid6.7 Well, I went to Studies, Edit Studies, Create, and I pasted your code into the thinkScript editor. I then saved it, and added a chart with that as the only study, and then made the chart settings you suggest. The problem I am having is that it is only showing me 11 bars way on the left side of the chart, and 11 more way over on the right, with nothing in between. That's with the period set to 6 mos or a year. If I set it to 5 years, then I get only bars on the far right. I can zoom the chart in on those, I guess, and then it would look something like yours.

Is that what I'm supposed to do?

Also, how would I make the down sections red instead of (I think) filled green? I'm struggling a bit with determining which is which with everything in green.
 
Last edited:
@sid6.7 Well, I went to Studies, Edit Studies, Create, and I pasted your code into the thinkScript editor. I then saved it, and added a chart with that as the only study, and then made the chart settings you suggest. The problem I am having is that it is only showing me 11 bars way on the left side of the chart, and 11 more way over on the right, with nothing in between. That's with the period set to 6 mos or a year. If I set it to 5 years, then I get only bars on the far right. I can zoom the chart in on those, I guess, and then it would look something like yours.

Is that what I'm supposed to do?

Also, how would I make the down sections red instead of (I think) filled green? I'm struggling a bit with determining which is which with everything in green.
It was a pretty rough script to figure out. It probably needs more polish which I haven't had much time to even look at doing that. Also, I am not entirely sure how point and figure charts work. I was not even intending to do it, but since I was already so close, I decided to take a stab at it for this board.

The left side, and right side, should match (the left side bars are mirrored to the right side), and the middle is empty. The original goal was to shift the bars to the right, so it would be zoomed in on automatically, however, that did not work, so you do need to zoom manually in on it to see it. There might be only 11 bars, because it only makes a new bar when the reverse price is hit (the p and f code is based on atr/2). The Solid Green is a down/red bar, the Hollow Green is an up/green bar. The method which actually plots bars "AddChart", is undocumented. I could not get the color to change, and have not been able to find documentation to explain how it actually works. The colors are already coded, but it does not appear to work.

I tried to add some comments throughout the code, so if someone wanted to modify it, or try to make it better. I hope this answers your questions.
 

New Indicator: Buy the Dip

Check out our Buy the Dip indicator and see how it can help you find profitable swing trading ideas. Scanner, watchlist columns, and add-ons are included.

Download the indicator

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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