#### BenTen

##### Administrative

**Staff**

**VIP**

**Warehouse**

This indicator was created for ThinkorSwim based on Bulkowski's Double Bottom Setup. You can learn more about the pattern, examples, and how to trade it here.

The Bulkowski Double Bottom indicator highlights a few things on your chart:

The Bulkowski Double Bottom indicator highlights a few things on your chart:

- First Pivot
- Pivot Low
- Double Bottom Price
- Breakout Price

### thinkScript Code

Rich (BB code):

```
# Bulkowski Double Bottom Pattern
# TASC Aril 2019
# Nube 3.30.19
# v 0.02, unsuccessfully trying to mark the first pivot of the pattern
# INPUTS
input pivotLength = 4;
input maxDoubleBottomWidth = 24;
input tolerancePercentage = 1.5;
input ticksAboveDoubleBottomHigh = 1;
# VARIABLES
# Universal
def h = high;
def l = low;
def nan = Double.NaN;
def x = BarNumber();
def tick = TickSize();
# Study Specific
def lowPivotBar = if !GetMinValueOffset(l, pivotLength + 1)
and GetMinValueOffset(l, pivotLength + 1)[-pivotLength + 1] ==
pivotLength - 1
then x
else lowPivotBar[1];
def lowPivot = if x == lowPivotBar
then x
else nan;
def lowPivotPrice = if x == lowPivotBar
then l
else lowPivotPrice[1];
def priorLowPivotBar = if lowPivotBar != lowPivotBar[1]
then lowPivotBar[1]
else priorLowPivotBar[1];
def priorLowPivotPrice = if x == lowPivotBar
then GetValue(l, lowPivotBar - priorLowPivotBar)
else priorLowPivotPrice[1];
def hh = if x crosses above lowPivotBar
then h
else if h > hh[1]
then h
else hh[1];
def highBetweenPivots = if x == lowPivotBar
then hh
else highBetweenPivots[1];
# Checking for pivot lows being within tolerancePercentage
def doubleBottom = if Between(lowPivotPrice,
priorLowPivotPrice * (1 - tolerancePercentage * .01),
priorLowPivotPrice * (1 + tolerancePercentage * .01))
and lowPivotBar - priorLowPivotBar <= maxDoubleBottomWidth
then Min(lowPivotPrice,priorLowPivotPrice)
else nan;
# invalidating pattern when price breaks below the doubleBottom price
def valid = if IsNaN(doubleBottom[1])
and !IsNaN(doubleBottom)
then 1
else if l crosses below doubleBottom
then 0
else valid[1];
# Plots
plot
PivotLow = x == lowPivotBar;
PivotLow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
PivotLow.SetDefaultColor(Color.Red);
plot
DoubleBottomPrice = if valid then doubleBottom else nan;
DoubleBottomPrice.SetDefaultColor(Color.Red);
DoubleBottomPrice.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
plot
BreakoutPrice = if DoubleBottomPrice
then highBetweenPivots + ticksAboveDoubleBottomHigh * tick
else nan;
BreakoutPrice.SetDefaultColor(Color.Green);
BreakoutPrice.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
AddChartBubble(DoubleBottomPrice and IsNaN(DoubleBottomPrice[-1]),
DoubleBottomPrice, DoubleBottomPrice+"
Bottomm Price
", Color.Red, 0);
AddChartBubble(BreakoutPrice and IsNaN(BreakoutPrice[-1]),
BreakOutPrice, "Breakout Price
"+ BreakOutPrice, Color.Green);
# f/ Bulkowski Double Bottom Pattern from April 2019 TASC this section still incorrect. Attempting to mark first pivot
def untilDB = fold i = -maxDoubleBottomWidth + 1 to 0
with u
while IsNaN(doubleBottom)
do u + GetValue(IsNaN(doubleBottom), i);
def firstPivot = !IsNaN(lowPivot) and
IsNaN(GetValue(doubleBottom, -untilDB)) and
Between(GetValue(doubleBottom, -untilDB -1),
l * (1 - tolerancePercentage * .01),
l * (1 + tolerancePercentage * .01));
AddChartBubble(firstPivot, l, "First Pivot", Color.Red, 0);
```

### Shareable Link

http://tos.mx/7678EI
Last edited: