PersonsPivots (PPS) Indicator for ThinkorSwim

2sureshk

Member
VIP
Person's Pivots (PPS) is a technical indicator in thinkorswim that's a variation of the Pivot Points study. It's a bullish and bearish momentum indicator that uses pivot points to plot one support level and one resistance level:
Bullish market: S1 and R2
Bearish market: S2 and R1
Neutral market: S1 and R1
The type of market is determined by comparing the pivot point to its three-day average. PPS also uses two proprietary moving average settings to help visualize market conditions.
PPS differs from Pivot Points in that it calculates levels using the last complete time period (week or month), while Pivot Points counts periods back from the last day. This means that pivot levels in PPS remain constant after being calculated at the beginning of a week or month, while Pivot Points levels change every day.


Mobius made a replica of the PersonsPivots indicator. It is good in 4 hrs and 2 hrs timeframe.

wvijraC.png

mod note:
a slightly different version can be found:
https://usethinkscript.com/threads/...cator-for-thinkorswim.1190/page-2#post-143294
Code:
# PPS replica
# Mobius

input n  = 2;
input n2 = 7;
input n3 = 5;
input n4 = 4;

def c = close;

plot data  = Average(Inertia(c, n), n2);
plot data2 = ExpAverage(Inertia(ohlc4, n3), n4);

#Stan this is a better statement for the arrows in the PPS:
plot ArrowUP = data crosses above data2 and close crosses above data2;
ArrowUP.SetPaintingStrategy(PaintingStrategy.Boolean_Arrow_UP);

Plot ArrowDN = close crosses below data2 and data crosses below data2;
ArrowDN.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
 
Last edited by a moderator:
Here is the code with alerts, although it uses PPS, but PPS original code is still not revealed. Has alerts

Code:
input ArrowsOn = yes;
input TracerLinesOn = no;
input PriceColorOn = Yes;
AddLabel(PriceColorOn, "SH PriceColorOn");

input ShowTodayOnly = no;
input ShowExtraDays = 0;
def Today =
if !ShowTodayOnly then 1 else
if GetDay() + ShowExtraDays >= GetLastDay() && GetYear() == GetLastYear() then 1 else 0;
input ArrowSpace = .233;
def space = Average(high - low) * ArrowSpace;

#Input AlertsOn = no;
#AddChartLabel(AlertsOn, "SH AlertsOn");
def BuyIt = PPS().buysignal;
def SellIt = PPS().sellsignal;

plot ppsBuy = if !Today or !ArrowsOn then Double.NaN else BuyIt - space;
ppsBuy.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
ppsBuy.SetDefaultColor(Color.WHITE);
ppsBuy.SetLineWeight(3);
Alert(ppsBuy, “PPS Buy Signal”, Alert.BAR, Sound.Ring);

plot ppsSell = if !Today or !ArrowsOn then Double.NaN else SellIt + space;
ppsSell.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
ppsSell.SetDefaultColor(Color.WHITE);
ppsSell.SetLineWeight(3);
Alert(ppsSell, “PPS Sell Signal”, Alert.BAR, Sound.Ring);


AddLabel(ArrowsOn, "WhiteArrows=SH", Color.WHITE);

rec PriceAtBuy = if BarNumber() == 1 then close else if !IsNaN(BuyIt[0]) then open[0] else PriceAtBuy[1];
rec PriceAtSell = if BarNumber() == 1 then close else if !IsNaN(SellIt[0]) then open[0] else PriceAtSell[1];


rec trigger = if PriceAtBuy <> PriceAtBuy[1] then -1 else if PriceAtSell <> PriceAtSell[1] then 1 else trigger[1];
plot BuyPrice = if TracerLinesOn && trigger == -1 then PriceAtBuy else Double.NaN;
BuyPrice.SetDefaultColor(Color.GREEN);
BuyPrice.SetPaintingStrategy(PaintingStrategy.POINTS);
plot SellPrice = if TracerLinesOn && trigger == 1 then PriceAtSell else Double.NaN;
SellPrice.SetDefaultColor(Color.RED);
SellPrice.SetPaintingStrategy(PaintingStrategy.POINTS);

AssignPriceColor(if !PriceColorOn then Color.CURRENT else if trigger == 1 then Color.RED else Color.GREEN);
 
PPS Buy and Sell watchlist:

Code:
def buy = !IsNaN(PPS().”BuySignal”[1]);
def sell = !IsNaN(PPS().”SellSignal”[1]);

AddLabel(yes, if buy then "Buy Fired" else if  sell then "Sell Fired" else " ");
AssignBackgroundColor(if buy then color.green else if sell then color.red else color.black);
 
Last edited by a moderator:
@horserider I was also unsure about the PPS signal since the source code isnt available but I tried my hand at referencing the buy signal in "def ppsBuy = PPS().BuySignal is true within 3 bars;" as I've seen studies referenced this way in the past. There may be an issue as far as input length for the PPS now that I am looking at it a second time and thinking about how the study works. Would an IsNaN function have to be used for pps? I am not sure if it is a number output or not.
 
@boogieG Yes hidden code makes it difficult. I decided to play a bit and since the PPS is just 2 moving averages I believe you can closely approximate the PPS signals with just doing your own moving average crosses. Simple moving averages of 4 and 7. Put the crosses into your code and that may solve the PPS issue. Feel free to experiment with other types of moving averages if you think you can get a better match. Hmmm why hide what appears to be very simple code.
 
I have since acquired a column that seems to work fine. PPS may not be the holy grail but it sure can help alert you to potential reversals in any time frame.

Code:
###### PPS ###############################
def xDays = 1;
def ppsBuy = PPS().BuySignal;
def buy = !IsNaN(ppsBuy);
def ppsSell = PPS().SellSignal;
def sell = !IsNaN(ppsSell);

plot value =
         if buy then 4
    else if sell then 1
    else 0;
value.assignValueColor(
         if value == 4 then color.light_green
    else if value == 1 then color.dark_red
    else color.black);
assignBackgroundColor(
         if value == 4 then color.light_green
    else if value == 1 then color.dark_red
    else color.black);
##########################################
 
I'm really (really) new to this stuff, but I think some of the above posts were asking for something like this (uses the PPS() buy and sell signals to create orders for a strategy).

Doesn't actually uncover what was coded for PPS, but uses the outputs.

Code:
plot buySignal = PPS().buysignal;
plot sellSignal = PPS().sellsignal;
plot slowAvg = PPS().slowavg;
plot fastAvg = PPS().fastavg;

AddOrder(OrderType.BUY_TO_OPEN, buySignal, tickColor = Color.DARK_ORANGE, arrowColor = Color.DARK_ORANGE, name = "PPS Buy");
AddOrder(OrderType.SELL_TO_CLOSE, sellSignal, tickColor = Color.GREEN, arrowColor = Color.GREEN, name = "PPS Sell");
 
As others have tried, I am trying to find something close to whatever formula weights the crossing SMA's to give the buy / sell signals with the PPS. If anyone has any input besides the composition of the averages, please do share. And for anyone that wants the PPS as a color coded column for a watchlist or in a scan, please see the code below. It really helps for confirmation on entry / exit. I've had it for a few years and most of the credit goes out to Pete Han and probably some other sources...I just remember finding some code, tweaking it and asking for some help. Its just to use as a column code, so you can adjust the timeframes in the "create custom code" window and save it as such. I don't think it is able to be adjusted to give exact prices at the time of the signal execution, just the close of the particular candle. If that is possible it would be a great addition. Enjoy.

Code:
#################################################
def buy = !IsNaN(PPS().”buySignal”);
def sell = !IsNaN(PPS().”SellSignal”);
rec closeAtBuy = if buy then close else closeAtBuy[1];
rec closeAtSell = if sell then close else closeAtSell[1];
rec state = if buy then 1 else if sell then -1 else state[1];
plot data = if state == 1 then closeAtBuy else closeAtSell;
data.AssignValueColor(if state == 1 then Color.BLACK else if state == -1 then Color.WHITE else Color.BLACK);
AssignBackGroundColor(if state == 1 then Color.GREEN else if state == -1 then Color.RED else Color.CURRENT);
##################################################

epSaboj.jpg


If the mods can grab that pic an attach it to this post, I'd appreciate it.
 
Does anyone have the PPS script in Multi TimeFrame, for example i would like to use the up and down arrows of a PPS of 1HR into a lower timeframe. If anyone has it can you please share it, or if anyone can make it I would greatly apprceated.
 
The source code for the PPS indicator is not available in ThinkorSwim, I had to use a replica by Mobius and turn it into an MTF indicator.

Code:
# PPS Replica_Mobius
# Added MTF by BenTen at UseThinkScript.com

input aggregationPeriod = AggregationPeriod.DAY;
def close = close(period = aggregationPeriod);
def open = open(period = aggregationPeriod);
def high = high(period = aggregationPeriod);
def low = low(period = aggregationPeriod);

def ohlc4 = (open + high + low + close) / 4;

input n  = 2;
input n2 = 7;
input n3 = 5;
input n4 = 4;

def c = close;

plot data  = Average(Inertia(c, n), n2);
plot data2 = ExpAverage(Inertia(ohlc4, n3), n4);

#Stan this is a better statement for the arrows in the PPS:
plot ArrowUP = data crosses above data2 and close crosses above data2;
ArrowUP.SetPaintingStrategy(PaintingStrategy.Boolean_Arrow_UP);

Plot ArrowDN = close crosses below data2 and data crosses below data2;
     ArrowDN.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
 
I am wondering if someone can put together a scan for stocks in an uptrend that are at or near weekly S1 support using Person pivots. Alternatively at R1 in a downtrend. Any help with this is greatly appreciated.

I am trying to get a scan when stocks get close to the weekly support level.
 
Last edited by a moderator:
@antbug Did you try any of these studies?
https://usethinkscript.com/threads/personspivots-pps-indicator-for-thinkorswim.1190/

I haven't used these studies personally but given that the title of the thread is Person Pivots and you are asking for Person Pivots. I am thinking you might want to plug&play a few of the studies that the other posters have shared to see if they give you what you need. Feel free to ask some of those posters that contributed any questions that you might have.
 
This was in an earlier reply on this thread and I'd like to use it. It looks like it works as a watchlist. I've saved the code as a study but it does not show up in the list when I try to customize my watch list? Can someone help me? Also, where in the code does this specify which time frames? Or am I just seeing a part of the puzzle? Thanks!!


from Dec 29, 2020 post above:


As others have tried, I am trying to find something close to whatever formula weights the crossing SMA's to give the buy / sell signals with the PPS. If anyone has any input besides the composition of the averages, please do share. And for anyone that wants the PPS as a color coded column for a watchlist or in a scan, please see the code below. It really helps for confirmation on entry / exit. I've had it for a few years and most of the credit goes out to Pete Han and probably some other sources...I just remember finding some code, tweaking it and asking for some help. Its just to use as a column code, so you can adjust the timeframes in the "create custom code" window and save it as such. I don't think it is able to be adjusted to give exact prices at the time of the signal execution, just the close of the particular candle. If that is possible it would be a great addition. Enjoy.

Code:
#################################################
def buy = !IsNaN(PPS().”buySignal”);
def sell = !IsNaN(PPS().”SellSignal”);
rec closeAtBuy = if buy then close else closeAtBuy[1];
rec closeAtSell = if sell then close else closeAtSell[1];
rec state = if buy then 1 else if sell then -1 else state[1];
plot data = if state == 1 then closeAtBuy else closeAtSell;
data.AssignValueColor(if state == 1 then Color.BLACK else if state == -1 then Color.WHITE else Color.BLACK);
AssignBackGroundColor(if state == 1 then Color.GREEN else if state == -1 then Color.RED else Color.CURRENT);
##################################################

View attachment 14179
 
This was in an earlier reply on this thread and I'd like to use it. It looks like it works as a watchlist. I've saved the code as a study but it does not show up in the list when I try to customize my watch list? Can someone help me? Also, where in the code does this specify which time frames? Or am I just seeing a part of the puzzle? Thanks!!


from Dec 29, 2020 post above:


As others have tried, I am trying to find something close to whatever formula weights the crossing SMA's to give the buy / sell signals with the PPS. If anyone has any input besides the composition of the averages, please do share. And for anyone that wants the PPS as a color coded column for a watchlist or in a scan, please see the code below. It really helps for confirmation on entry / exit. I've had it for a few years and most of the credit goes out to Pete Han and probably some other sources...I just remember finding some code, tweaking it and asking for some help. Its just to use as a column code, so you can adjust the timeframes in the "create custom code" window and save it as such. I don't think it is able to be adjusted to give exact prices at the time of the signal execution, just the close of the particular candle. If that is possible it would be a great addition. Enjoy.

Code:
#################################################
def buy = !IsNaN(PPS().”buySignal”);
def sell = !IsNaN(PPS().”SellSignal”);
rec closeAtBuy = if buy then close else closeAtBuy[1];
rec closeAtSell = if sell then close else closeAtSell[1];
rec state = if buy then 1 else if sell then -1 else state[1];
plot data = if state == 1 then closeAtBuy else closeAtSell;
data.AssignValueColor(if state == 1 then Color.BLACK else if state == -1 then Color.WHITE else Color.BLACK);
AssignBackGroundColor(if state == 1 then Color.GREEN else if state == -1 then Color.RED else Color.CURRENT);
##################################################

epSaboj.jpg
This is a script I use on columns in my watchlist. You would need to customize the columns in your watchlist and use this code in one of the "custom" tabs. You can adjust the timeframe in each custom column as needed. For more info search the forum for "custom watchlist column"

If you choose to use it as a study you would be limited to the chart time period. You would also need to incorporate a label with color changes depending on if the current price was greater or lower than the pps signal.
 
Here is the code with alerts, although it uses PPS, but PPS original code is still not revealed. Has alerts

Code:
input ArrowsOn = yes;
input TracerLinesOn = no;
input PriceColorOn = Yes;
AddLabel(PriceColorOn, "SH PriceColorOn");

input ShowTodayOnly = no;
input ShowExtraDays = 0;
def Today =
if !ShowTodayOnly then 1 else
if GetDay() + ShowExtraDays >= GetLastDay() && GetYear() == GetLastYear() then 1 else 0;
input ArrowSpace = .233;
def space = Average(high - low) * ArrowSpace;

#Input AlertsOn = no;
#AddChartLabel(AlertsOn, "SH AlertsOn");
def BuyIt = PPS().buysignal;
def SellIt = PPS().sellsignal;

plot ppsBuy = if !Today or !ArrowsOn then Double.NaN else BuyIt - space;
ppsBuy.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
ppsBuy.SetDefaultColor(Color.WHITE);
ppsBuy.SetLineWeight(3);
Alert(ppsBuy, “PPS Buy Signal”, Alert.BAR, Sound.Ring);

plot ppsSell = if !Today or !ArrowsOn then Double.NaN else SellIt + space;
ppsSell.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
ppsSell.SetDefaultColor(Color.WHITE);
ppsSell.SetLineWeight(3);
Alert(ppsSell, “PPS Sell Signal”, Alert.BAR, Sound.Ring);


AddLabel(ArrowsOn, "WhiteArrows=SH", Color.WHITE);

rec PriceAtBuy = if BarNumber() == 1 then close else if !IsNaN(BuyIt[0]) then open[0] else PriceAtBuy[1];
rec PriceAtSell = if BarNumber() == 1 then close else if !IsNaN(SellIt[0]) then open[0] else PriceAtSell[1];


rec trigger = if PriceAtBuy <> PriceAtBuy[1] then -1 else if PriceAtSell <> PriceAtSell[1] then 1 else trigger[1];
plot BuyPrice = if TracerLinesOn && trigger == -1 then PriceAtBuy else Double.NaN;
BuyPrice.SetDefaultColor(Color.GREEN);
BuyPrice.SetPaintingStrategy(PaintingStrategy.POINTS);
plot SellPrice = if TracerLinesOn && trigger == 1 then PriceAtSell else Double.NaN;
SellPrice.SetDefaultColor(Color.RED);
SellPrice.SetPaintingStrategy(PaintingStrategy.POINTS);

AssignPriceColor(if !PriceColorOn then Color.CURRENT else if trigger == 1 then Color.RED else Color.GREEN);
hello it is scan for this great system? thanks in advance
 
Hello,
I know this is an old thread but thought I would try my question.
The code in the beginning with pps with alerts draws lines when it triggers a signal but the lines are at the open of the trigger bar instead of the close of the trigger bar. It could also be from the open of the next bar but drawing from the open of the trigger bar is misleading. Can someone help modify this code to draw the line accurately? Thanks
 
Hello,
I know this is an old thread but thought I would try my question.
The code in the beginning with pps with alerts draws lines when it triggers a signal but the lines are at the open of the trigger bar instead of the close of the trigger bar. It could also be from the open of the next bar but drawing from the open of the trigger bar is misleading. Can someone help modify this code to draw the line accurately? Thanks

See if this helps

Screenshot-2022-12-23-130505.png
Ruby:
input ArrowsOn = yes;
input TracerLinesOn = no;
input PriceColorOn = Yes;
AddLabel(PriceColorOn, "SH PriceColorOn");

input ShowTodayOnly = no;
input ShowExtraDays = 0;
def Today =
if !ShowTodayOnly then 1 else
if GetDay() + ShowExtraDays >= GetLastDay() && GetYear() == GetLastYear() then 1 else 0;
input ArrowSpace = .233;
def space = Average(high - low) * ArrowSpace;

#Input AlertsOn = no;
#AddChartLabel(AlertsOn, "SH AlertsOn");
def BuyIt = PPS().buysignal;
def SellIt = PPS().sellsignal;

plot ppsBuy = if !Today or !ArrowsOn then Double.NaN else BuyIt - space;
ppsBuy.SetPaintingStrategy(PaintingStrategy.ARROW_UP);
ppsBuy.SetDefaultColor(Color.WHITE);
ppsBuy.SetLineWeight(3);
Alert(ppsBuy, “PPS Buy Signal”, Alert.BAR, Sound.Ring);

plot ppsSell = if !Today or !ArrowsOn then Double.NaN else SellIt + space;
ppsSell.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
ppsSell.SetDefaultColor(Color.WHITE);
ppsSell.SetLineWeight(3);
Alert(ppsSell, “PPS Sell Signal”, Alert.BAR, Sound.Ring);


AddLabel(ArrowsOn, "WhiteArrows=SH", Color.WHITE);

rec PriceAtBuy = if BarNumber() == 1 then close else if !IsNaN(BuyIt[0]) then close[0] else PriceAtBuy[1];
rec PriceAtSell = if BarNumber() == 1 then close else if !IsNaN(SellIt[0]) then close[0] else PriceAtSell[1];


rec trigger = if PriceAtBuy <> PriceAtBuy[1] then -1 else if PriceAtSell <> PriceAtSell[1] then 1 else trigger[1];
plot BuyPrice = if TracerLinesOn && trigger == -1 then PriceAtBuy else Double.NaN;
BuyPrice.SetDefaultColor(Color.white);
BuyPrice.SetPaintingStrategy(PaintingStrategy.POINTS);
plot SellPrice = if TracerLinesOn && trigger == 1 then PriceAtSell else Double.NaN;
SellPrice.SetDefaultColor(Color.yellow);
SellPrice.SetPaintingStrategy(PaintingStrategy.POINTS);

AssignPriceColor(if !PriceColorOn then Color.CURRENT else if trigger == 1 then Color.RED else Color.GREEN);
 
I would like to add a bubble only when the PPS indicator has a buy signal and the arrow is higher than the previous one.
The bubble will have the arrow number up, example 1,2,3,4 etc...
When the next buy arrow is lower then the counter reset

I do not why the replica does not work for me (different signals from the original). Any idea?
 
Last edited by a moderator:
All of John L. Person's pivot work, calculations and formulas are spelled out clearly in his book "Candlestick and Pivot Point Trading Triggers." I have turned the PPS and other Person work into TOS indicators that I "fancied" up and personalised. The book is an easy read and explains how Mr. Person recommends using the indicators and is a must read if you will be using them. I got the book at the public library, and should be available at your local library, just check for it online. The book is not worth a buy if you take good notes. The only caveat is Mr. Person has a pretty big opinion of himself, and says so many, MANY times in the book. IMHO, Scott
 

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