Pocket Pivot Points Indicator and Scanner for ThinkorSwim

This indicator is for pocket pivot BUYs. Can someone write the code for pivot SELLs? Thanks!
Just invert the chart by adding minus "-" sign within chart and not on the study itself. The chart will invert and the Signal will show up if it fits the definition. I do this regularly. See latest QQQ inverted chart below. Blue bubbles are all pocketpivot price-volume signatures.

Clanky but it works.

I used to subscribe to Dr. Chris Kacher's (originator of pocket pivot buy signal) https://www.virtueofselfishinvesting.com premium membership years ago. It was repeatedly mentioned that the signal works bought ways.

Dr. Kacher's only volume signature requirement remains both ways (signal volume must be higher than any previous opposite volume within 10 ticks; (ie if Buy signal: current volume must be higher than any price Lows volume within 10 ticks/ if Sell signal: current volume must be higher than any price Highs volume within 10 ticks)

(Edited to include Volume in the image.)

n3n2ZAX.png
 
Last edited by a moderator:
Pocket pivots were originally designed by Chris Kacher to combat sideways market. Back then it was difficult to trade base breakouts and often always a failure. The concept of Pocket Pivots came out of this. It allows traders to get an early entry on the stock before it breaks out of its base.

Developer Scott Johnson was able to take this concept and created a Pocket Pivot indicator for ThinkorSwim users. He wrote a lot of notes in his script and most of them are important points to note. I had to take it out and quote it here instead. Scott, if you're reading this I have no intention of messing with your code or trying to modify it.



View attachment 4649

View attachment 4651

thinkScript Code

Rich (BB code):
# Copyright 2015 Scott J. Johnson (http://scottjjohnson.com)
input Period = 11;  # normal volume lookback period (today + 10 prior days)
input MaximumDistanceFrom10DaySMAPercent = 1.4;  # Price on pivot day should be near the 10-day SMA.  MAX = 1.6 Per FOSL1, 1.23 per PII, but RAX not extended at 1.61 and 1.64.

# Volume functions
def DownVolume = If(close < close[1], volume, 0);
def HighestDownVolume = Highest(DownVolume, Period);

def FiftyDayAverageVolume = MovingAverage(AverageType.SIMPLE, volume, 50);

def IsVolumeGreaterHighestDownVolume = if (volume > HighestDownVolume) then 1 else 0;

# Price functions
def TenDaySMA = MovingAverage(AverageType.SIMPLE, close, 10);
def FiftyDaySMA = MovingAverage(AverageType.SIMPLE, close, 50);

def IsLowPriceNear10DaySMA = if ((AbsValue(low - TenDaySMA) / TenDaySMA) <= MaximumDistanceFrom10DaySMAPercent / 100) then 1 else 0;
def DidPricePass10DaySMA = if (low <= TenDaySMA && close >= TenDaySMA) then 1 else 0;

def IsPriceNear10DaySMA = if (IsLowPriceNear10DaySMA or DidPricePass10DaySMA) then 1 else 0;

def IsPriceAtOrAbove50DaySMA = if (close >= FiftyDaySMA) then 1 else 0;

def AveragePriceChangePercent = MovingAverage(AverageType.SIMPLE, AbsValue(close[1] - close[2]) / close[2], Period);

def IsCloseInUpperHalfOfRange = close >= close[1] && close > ((high - low) * .38 + low);

def IsPriceInTheProperRange = if (IsCloseInUpperHalfOfRange && IsPriceNear10DaySMA && IsPriceAtOrAbove50DaySMA) then 1 else 0;

# add a chart bubble if then PP criteria are met
AddChartBubble(IsVolumeGreaterHighestDownVolume && IsPriceInTheProperRange, low, "PP", Color.CYAN, no);

#Scan
def PParrow = IsVolumeGreaterHighestDownVolume and IsPriceInTheProperRange;
plot PP = PParrow;
PP.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
PP.SetLineWeight(2);
PP.AssignValueColor(Color.WHITE);

Shareable Link

https://tos.mx/os8Hki

Pocket Pivot Long Strategy

Code:
# Copyright 2015 Scott J. Johnson (http://scottjjohnson.com)
# Licensed under the Apache License, Version 2.0
# PocketPivotStrategyLE
# Identifies Pocket Pivot buy points.  This is a copy of the PocketPivot study.
# Unfortunately I have to copy the entire logic here rather than just referencing
# the study.  See PocketPivotSTUDY.ts for a description of the study.

declare hide_on_intraday;

input Period = 11;  # normal volume lookback period (today + 10 prior days)
input MaximumDistanceFrom10DaySMAPercent = 1.4;  # Price on pivot day should be near the 10-day SMA.  MAX = 1.6 Per FOSL1, 1.23 per PII, but RAX not extended at 1.61 and 1.64.

# Volume functions
def DownVolume = If(close < close[1], volume, 0);
def HighestDownVolume = Highest(DownVolume, Period);

def FiftyDayAverageVolume = MovingAverage(AverageType.SIMPLE, volume, 50);

def IsVolumeGreaterHighestDownVolume = if (volume > HighestDownVolume) then 1 else 0;

# Price functions
def TenDaySMA = MovingAverage(AverageType.SIMPLE, close, 10);
def FiftyDaySMA = MovingAverage(AverageType.SIMPLE, close, 50);

def IsLowPriceNear10DaySMA = if ((AbsValue(low - TenDaySMA) / TenDaySMA) <= MaximumDistanceFrom10DaySMAPercent / 100) then 1 else 0;
def DidPricePass10DaySMA = if (low <= TenDaySMA && close >= TenDaySMA) then 1 else 0;

def IsPriceNear10DaySMA = if (IsLowPriceNear10DaySMA or DidPricePass10DaySMA) then 1 else 0;

def IsPriceAtOrAbove50DaySMA = if (close >= FiftyDaySMA) then 1 else 0;

def AveragePriceChangePercent = MovingAverage(AverageType.SIMPLE, AbsValue(close[1] - close[2]) / close[2], Period);

def IsCloseInUpperHalfOfRange = close >= close[1] && close > ((high - low) * .38 + low);

def IsPriceInTheProperRange = if (IsCloseInUpperHalfOfRange && IsPriceNear10DaySMA && IsPriceAtOrAbove50DaySMA) then 1 else 0;

# add a chart bubble if then PP criteria are met
# AddChartBubble(IsVolumeGreaterHighestDownVolume && IsPriceInTheProperRange, low, "PP", Color.CYAN, no);

# add a chart bubble if then PP criteria are met
def buy = if (IsVolumeGreaterHighestDownVolume && IsPriceInTheProperRange) then 1 else 0;

AddOrder(OrderType.BUY_TO_OPEN, buy equals 1, tickColor = GetColor(0), arrowColor = GetColor(0), price = close, name = "Buy");

Pocket Pivot Short Strategy

Code:
# Copyright 2015 Scott J. Johnson (http://scottjjohnson.com). Licensed under the Apache License, Version 2.0
# PocketPivotStrategyLX
# Sell when we break the 10/50 day line on day 1 and then go below that day's intraday
# low on a subsequent day.  Also sell if we break the 50-day on volume more than 40%
# above average.

input MovingAverageLine = 50; # sell when violates 50 day SMA
input HighVolumePercentage = 40; # if volume is greater or equal that this percentage
                                 # above the 50-day average volume then it counts
                                 # as a high volume day.

def TodaysSMA = MovingAverage(AverageType.SIMPLE, close[1], MovingAverageLine);
def YesterdaysSMA = MovingAverage(AverageType.SIMPLE, close[1], MovingAverageLine);

# volume rule always uses the 50-day, but the SMA violation run can be 10- or 50-day
def Todays50DaySMA = MovingAverage(AverageType.SIMPLE, close[1], 50);
def AverageVolume = MovingAverage(AverageType.SIMPLE, volume[1], 50);

def DidViolateSMA = if (low < low[1] && close[1] < YesterdaysSMA) then 1 else 0;
def DidBreakSMAOnHighVolume = if (close<Todays50DaySMA && volume > AverageVolume * (1 + HighVolumePercentage/100)) then 1 else 0;

def sell = if (DidViolateSMA or DidBreakSMAOnHighVolume) then 1 else 0;

AddOrder(OrderType.SELL_TO_CLOSE, sell equals 1, tickColor = GetColor(1), arrowColor = GetColor(1), price = low[1], name = "Sell");

Additional Resources:


I added a scanner into that indicator just in case anyone would like to scan for Pocket Pivot on their charts.
Hello, is there any way to alter the scan so it searches stocks that have had pocket pivots occur at any point over a certain period of time? For example, any stock that has had a pocket pivot over the past 3 weeks, instead of scanning only for ones that occurred just the day prior. I would like to only include stocks that have had a pocket pivot occur along with other filters I have.
 

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