Automatic Wedge Pattern Detector for ThinkorSwim

BenTen

BenTen

Administrative
Staff
VIP
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.




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:
zeek

zeek

Active member
2019 Donor
Exactly what i’ve been looking for, thx @BenTen for the share👍
 
D

drjp384

New member
when u see wedge pattern ....either goes up and /or down after ...
 
W

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!
 
BenTen

BenTen

Administrative
Staff
VIP
@webdementia The arrow indicates a potential formation. You would have to draw the lines manually.
 
inthefutures

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
 
BenTen

BenTen

Administrative
Staff
VIP
@inthefutures What are you trying to modify? Stick with the original code and you should be fine.
 
inthefutures

inthefutures

Active member
i am doing nothing looks like you used fourbar twice but i will move on
 
horserider

horserider

Well-known member
VIP
plot up5 = FourBarsWedges;
plot down5 = FourBarsWedges;
o_O
Nice spot @inthefutures Original code should be corrected.
 
D

dreamb0x

New member
VIP
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?


 
BenTen

BenTen

Administrative
Staff
VIP
@dreamb0x See my comment #5. The arrows are there to help you identify potential formation. You have to connect the dots ;)

Here is a screenshot to give you the idea. Note: this indicator does not highlight all potential formations you see below.

 
V

Vorlauf

New member
Is it possible and how would this be made into a scanner?
 
A

amanrastogi1992

New member
@BenTen Can it be used for 5min and 15 min timeframes?
 
Top