# 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);