Automatic Wedge Pattern Detector for ThinkorSwim

BenTen

Administrative
Staff member
Staff
VIP
Lifetime
For fans of pure price action patterns. This indicator helps to identify and spot potential wedge patterns on your chart. This was put together by @korygill.

PQR2Xcu.png

6X9mhtS.png


The yellow arrows (up and down) suggested that there is a potential wedge pattern within the last 4 bars (including the candle with the arrows). White arrows (which are rare suggest there may be a wedge pattern within the last 5 bars). You can easily use this indicator with the scanner.

thinkScript Code

Code:
# Price Action Wedge Patterns
# Include Four and Five Bar Wedges
# Developed based on idea from BenTen of useThinkScript.com
# Study to indicate when a wedge may be forming.
# Author: Kory Gill, @korygill
# Version 1.0

declare upper;
declare once_per_bar;

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

def vHigh = high;
def vLow = low;
def nan = Double.NaN;

def range = vHigh - vLow;
def isInsideBar = if range < range[1] and vHigh < vHigh[1] and vLow > vLow[1]
                  then 1
                  else 0;

# Define 4 Bars Wedge
def FourBarsWedges = high < high[3] and high[0] < high[3] and high[1] < high[3] and high[2] < high[3] and
low > low[3] and low[0] > low[3] and low[1] > low[3] and low[2] > low[3];
plot up4 = FourBarsWedges;
plot down4 = FourBarsWedges;
up4.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
up4.SetLineWeight(1);
up4.AssignValueColor(Color.Yellow);
down4.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
down4.SetLineWeight(1);
down4.AssignValueColor(Color.Yellow);

# Define 5 Bars Wedge
def FiveBarsWedges = high < high[4] and high[1] < high[4] and high[2] < high[4] and high[3] < high[4] and
low > low[4] and low[1] > low[4] and low[2] > low[4] and low[3] > low[4];
plot up5 = FiveBarsWedges;
plot down5 = FiveBarsWedges;
up5.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
up5.SetLineWeight(1);
up5.AssignValueColor(Color.WHITE);
down5.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
down5.SetLineWeight(1);
down5.AssignValueColor(Color.WHITE);
 
Last edited:

webdementia

New member
Will this chart actually show the lines like that or just the arrows? I just installed it and I see neither. Actually I do see the arrows but its from 10 days back. Thanks!
 

inthefutures

Active member
ben
def FiveBarsWedges = high < high[4] and high[1] < high[4] and high[2] < high[4] and high[3] < high[4] and
low > low[4] and low[1] > low[4] and low[2] > low[4] and low[3] > low[4];
plot up5 = FourBarsWedges;
plot down5 = FourBarsWedges;


Is this correct plot up5 = fourbarswedge. should it not be fivebarwedge
 

dreamb0x

New member
trying to test this out but im not sure what went wrong?
i dont see the wedge drawing but the arrows are there.
any guidance on what settings should i change?


 

slrank82

New member
Hi Everyone, brand new to the forum and my coding experience pretty much non existent. I did a search and may have missed it, but @BenTen any tips on how I can take this code and make it into a watchlist column to alert me right when the yellow/white arrows are triggered? I have it in a column now but it is just showing a NaN in the column. I am assuming it is not formatted correctly.
 

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