All-in-One Bullish Candlestick Patterns in ThinkorSwim

BenTen

Administrative
Staff member
Staff
VIP
Lifetime
This indicator combines 20 bullish candlesticks and automatically plot them into your ThinkorSwim chart. Among these candlestick patterns, the bullish engulfing candle, hammer, piercing line, and morning star are the most popular.

Can be used with any timeframes, alerts and bubbles are available in the indicator's setting page.

iWV8yn7.png


thinkScript Code

Rich (BB code):
#Hint:<b>BullishCandlesticks(20)</b>\nPlots and identifies all 20 candlesticks or 3 individually selected candlesticks. Can be used with any aggregation period. Alerts, bubbles and labels may be toggled on/off. Within 'edit studies', any candle pattern can be isolated. A number-ID system is incorporated to enhance chart readability or the candle names may be used.



#Title = BullishCandlePlots

#Revision date 3:36 PM 9/29/2013

#Report any problems to 'StanL' on TOS' ThinkScript Lounge

declare upper;

declare once_per_bar;



input TurnAlertOff = yes;#hint TurnAlertOff:Turns on and off the alerts for any selected label that shows



input showLabel = yes;#hint showLabel:Turns on and off the showing of candle names in labels atop the plot



input showBubble = {default none, Verbose, ID_Number};#Hint showBubble:Choice of what format the candle bubble ID should have



input ShowAll = yes;#Hint ShowAll:A YES shows all candle where they exist. NO yturns off this plot so that individual candles may be selected in ShowFirst, ShowSecond or ShowThird.



def BubNone = If (showBubble == showBubble.none, 1, 0);

def BubVerb = If (showBubble == showBubble.Verbose, 1, 0);

def BubNumb =  If (showBubble == showBubble.ID_Number, 1, 0);



#####################################################

############ Define the three selection Enums #################

#####################################################

input ShowFirst = {default none, Hammer_1, InvertedHammer_2, ThreeOutsideUp_3,

 ThreeInsideUp_4, PiercingLine_5, ThreeWhiteSoldiers_6, MorningDojiStar_7, ConcealingBabySwallow_8, HighPriceGappingPlay_9, HomingPigeon_10, MatchingLow_11, MatHold_12, MorningStar_13, RisingThreeMethods_14, StickSandwich_15, ThreeStarsInTheSouth_16, UniqueThreeRiverBottom_17, UpsideGapThreeMethods_18, UpsideTasukiGap_19};#hint ShowFirst:Select the candle to show

input ShowSecond =  {default none, Hammer_1, InvertedHammer_2, ThreeOutsideUp_3,

 ThreeInsideUp_4, PiercingLine_5, ThreeWhiteSoldiers_6, MorningDojiStar_7, ConcealingBabySwallow_8, HighPriceGappingPlay_9, HomingPigeon_10, MatchingLow_11, MatHold_12, MorningStar_13, RisingThreeMethods_14, StickSandwich_15, ThreeStarsInTheSouth_16, UniqueThreeRiverBottom_17, UpsideGapThreeMethods_18, UpsideTasukiGap_19};#hint ShowSecond:Select the candle to show



input ShowThird =  {default none, Hammer_1, InvertedHammer_2, ThreeOutsideUp_3,

 ThreeInsideUp_4, PiercingLine_5, ThreeWhiteSoldiers_6, MorningDojiStar_7, ConcealingBabySwallow_8, HighPriceGappingPlay_9, HomingPigeon_10, MatchingLow_11, MatHold_12, MorningStar_13, RisingThreeMethods_14, StickSandwich_15, ThreeStarsInTheSouth_16, UniqueThreeRiverBottom_17, UpsideGapThreeMethods_18, UpsideTasukiGap_19};#hint ShowThird:Select the candle to show



###################################################

############ Process Input 'ShowFirst' Enum ##################

###################################################

def candle;

switch (ShowFirst) {

case Hammer_1:

    candle = If(ShowFirst.Hammer(), Hammer(), Double.NaN);

case InvertedHammer_2:

    candle =  If(ShowFirst.InvertedHammer(), InvertedHammer(), Double.NaN);

case ThreeOutsideUp_3:

    candle = If(ShowFirst.ThreeOutsideUp(), ThreeOutsideUp(), Double.NaN);

case ThreeInsideUp_4:

    candle = If(ShowFirst.ThreeInsideUp(), ThreeInsideUp(), Double.NaN);

case PiercingLine_5:

    candle = If(ShowFirst.PiercingLine(), PiercingLine(), Double.NaN);

case ThreeWhiteSoldiers_6:

    candle = If(ShowFirst.ThreeWhiteSoldiers(), ThreeWhiteSoldiers(), Double.NaN);

case MorningDojiStar_7:

    candle = If(ShowFirst.MorningDojiStar() , MorningDojiStar(), Double.NaN);

case ConcealingBabySwallow_8:

    candle = If(ShowFirst.ConcealingBabySwallow() , ConcealingBabySwallow(), Double.NaN);

case HighPriceGappingPlay_9:

    candle = If(ShowFirst.HighPriceGappingPlay()   , HighPriceGappingPlay(), Double.NaN);

case HomingPigeon_10:

    candle = If(ShowFirst.HomingPigeon()   , HomingPigeon(), Double.NaN);

case MatchingLow_11:

    candle = If(ShowFirst.MatchingLow()   , MatchingLow(), Double.NaN);

case MatHold_12:

    candle = If(ShowFirst.MatHold()   , MatHold(), Double.NaN);

case MorningStar_13:

    candle = If(ShowFirst.MatHold()  , MatHold(), Double.NaN);

case RisingThreeMethods_14:

    candle = If(ShowFirst.RisingThreeMethods()   , RisingThreeMethods(), Double.NaN);

case StickSandwich_15:

    candle = If(ShowFirst.StickSandwich() , StickSandwich(), Double.NaN);

case ThreeStarsInTheSouth_16:

    candle = If(ShowFirst.ThreeStarsInTheSouth()  , ThreeStarsInTheSouth(), Double.NaN);

case UniqueThreeRiverBottom_17:

    candle = If(ShowFirst.UniqueThreeRiverBottom()  , UniqueThreeRiverBottom(), Double.NaN);

case UpsideGapThreeMethods_18:

    candle = If(ShowFirst.UpsideGapThreeMethods()  , UpsideGapThreeMethods(), Double.NaN);

case UpsideTasukiGap_19:

    candle = If(ShowFirst.UpsideTasukiGap(), UpsideTasukiGap(), Double.NaN);

case none:

    candle = Double.NaN;

}  # Closing of switch (ShowFirst) {



plot Show1st = candle;

Show1st.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

Show1st.SetDefaultColor(Color.GREEN);

Show1st.SetLineWeight(5);

#####################################################

############ Process Input 'ShowSecond' Enum #################

#####################################################



def candle2;

switch (ShowSecond) {

case Hammer_1:

    candle2 = If(ShowSecond.Hammer() , Hammer(), Double.NaN);

case InvertedHammer_2:

    candle2 =  If(ShowSecond.InvertedHammer() , InvertedHammer(), Double.NaN);

case ThreeOutsideUp_3:

    candle2 = If(ShowSecond.ThreeOutsideUp() , ThreeOutsideUp(), Double.NaN);

case ThreeInsideUp_4:

    candle2 = If(ShowSecond.ThreeInsideUp() , ThreeInsideUp(), Double.NaN);

case PiercingLine_5:

    candle2 = If(ShowSecond.PiercingLine()   , PiercingLine(), Double.NaN);

case ThreeWhiteSoldiers_6:

    candle2 = If(ShowSecond.ThreeWhiteSoldiers()  , ThreeWhiteSoldiers(), Double.NaN);

case MorningDojiStar_7:

    candle2 = If(ShowSecond.MorningDojiStar()  , MorningDojiStar(), Double.NaN);

case ConcealingBabySwallow_8:

    candle2 = If(ShowSecond.ConcealingBabySwallow() , ConcealingBabySwallow(), Double.NaN);

case HighPriceGappingPlay_9:

    candle2 = If(ShowSecond.HighPriceGappingPlay()  , HighPriceGappingPlay(), Double.NaN);

case HomingPigeon_10:

    candle2 = If(ShowSecond.HomingPigeon()  , HomingPigeon(), Double.NaN);

case MatchingLow_11:

    candle2 = If(ShowSecond.MatchingLow()  , MatchingLow(), Double.NaN);

case MatHold_12:

    candle2 = If(ShowSecond.MatHold()  , MatHold(), Double.NaN);

case MorningStar_13:

    candle2 = If(ShowSecond.MatHold() , MatHold(), Double.NaN);

case RisingThreeMethods_14:

    candle2 = If(ShowSecond.RisingThreeMethods()  , RisingThreeMethods(), Double.NaN);

case StickSandwich_15:

    candle2 = If(ShowSecond.StickSandwich() , StickSandwich(), Double.NaN);

case ThreeStarsInTheSouth_16:

    candle2 = If(ShowSecond.ThreeStarsInTheSouth() , ThreeStarsInTheSouth(), Double.NaN);

case UniqueThreeRiverBottom_17:

    candle2 = If(ShowSecond.UniqueThreeRiverBottom() , UniqueThreeRiverBottom(), Double.NaN);

case UpsideGapThreeMethods_18:

    candle2 = If(ShowSecond.UpsideGapThreeMethods() , UpsideGapThreeMethods(), Double.NaN);

case UpsideTasukiGap_19:

    candle2 = If(ShowSecond.UpsideTasukiGap()  , UpsideTasukiGap(), Double.NaN);

case none:

    candle2 = Double.NaN;

}



plot Show2nd = candle2;

Show2nd.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

Show2nd.SetDefaultColor(Color.GREEN);

Show2nd.SetLineWeight(5);

###########################################################

############ Process Input 'Showthird' Enum ###############

###########################################################



def candle3;

switch (ShowThird) {

case Hammer_1:

    candle3 = If(ShowThird.Hammer() , Hammer(), Double.NaN);

case InvertedHammer_2:

    candle3 =  If(ShowThird.InvertedHammer() , InvertedHammer(), Double.NaN);

case ThreeOutsideUp_3:

    candle3 = If(ShowThird.ThreeOutsideUp() , ThreeOutsideUp(), Double.NaN);

case ThreeInsideUp_4:

    candle3 = If(ShowThird.ThreeInsideUp() , ThreeInsideUp(), Double.NaN);

case PiercingLine_5:

    candle3 = If(ShowThird.PiercingLine()   , PiercingLine(), Double.NaN);

case ThreeWhiteSoldiers_6:

    candle3 = If(ShowThird.ThreeWhiteSoldiers()  , ThreeWhiteSoldiers(), Double.NaN);

case MorningDojiStar_7:

    candle3 = If(ShowThird.MorningDojiStar()  , MorningDojiStar(), Double.NaN);

case ConcealingBabySwallow_8:

    candle3 = If(ShowThird.ConcealingBabySwallow() , ConcealingBabySwallow(), Double.NaN);

case HighPriceGappingPlay_9:

    candle3 = If(ShowThird.HighPriceGappingPlay()  , HighPriceGappingPlay(), Double.NaN);

case HomingPigeon_10:

    candle3 = If(ShowThird.HomingPigeon()  , HomingPigeon(), Double.NaN);

case MatchingLow_11:

    candle3 = If(ShowThird.MatchingLow()  , MatchingLow(), Double.NaN);

case MatHold_12:

    candle3 = If(ShowThird.MatHold()  , MatHold(), Double.NaN);

case MorningStar_13:

    candle3 = If(ShowThird.MatHold() , MatHold(), Double.NaN);

case RisingThreeMethods_14:

    candle3 = If(ShowThird.RisingThreeMethods()  , RisingThreeMethods(), Double.NaN);

case StickSandwich_15:

    candle3 = If(ShowThird.StickSandwich() , StickSandwich(), Double.NaN);

case ThreeStarsInTheSouth_16:

    candle3 = If(ShowThird.ThreeStarsInTheSouth() , ThreeStarsInTheSouth(), Double.NaN);

case UniqueThreeRiverBottom_17:

    candle3 = If(ShowThird.UniqueThreeRiverBottom() , UniqueThreeRiverBottom(), Double.NaN);

case UpsideGapThreeMethods_18:

    candle3 = If(ShowThird.UpsideGapThreeMethods() , UpsideGapThreeMethods(), Double.NaN);

case UpsideTasukiGap_19:

    candle3 = If(ShowThird.UpsideTasukiGap()  , UpsideTasukiGap(), Double.NaN);

case none:

    candle3 = Double.NaN;

}

plot Show3rd = candle3;

Show3rd.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

Show3rd.SetDefaultColor(Color.GREEN);

Show3rd.SetLineWeight(5);

########################################################

######## Then following applies to Show1st, Show2nd & Show3rd plots ##########

######## The conditions for all 3 plots are implemented ################

########################################################



##### 1 ################ Hammer() #############################

def ThreeShows_1 = If (ShowFirst == ShowFirst.Hammer_1 or ShowSecond == ShowSecond.Hammer_1 or ShowThird == ShowThird.Hammer_1, 1, 0);

rec Ham_Trig = If(Hammer().bullish , BarNumber(), Ham_Trig[1]);

#Def Ham_label = if(Trig_bar > 0, 1, 0);



AddLabel(Ham_Trig > 0  && showLabel  && ThreeShows_1, "1=Hammer" , Color.GREEN);



Alert(Hammer() && !TurnAlertOff, "HammerAlert", Alert.BAR, Sound.Chimes);

AddChartBubble(Hammer() && (BubVerb or BubNumb) && ThreeShows_1 , high ,  if BubNumb

then "1"

else if BubVerb

then "Hammer"

 else "" ,

  Color.WHITE , no);

###################### Debugging Labels ###############

#AddLabel(yes, Concat("Ham_Trig > 0 is = ", Ham_Trig > 0), Color.WHITE);

#AddLabel(yes, Concat("Total Bars = ", + BarNumber()), Color.WHITE);

#AddLabel(yes, Concat("Ham_Trig value = ", Ham_Trig), Color.WHITE);

#AddLabel(yes, Concat("ShowBubble = ", showBubble), Color.WHITE);

#AddLabel(yes, Concat("ShowFirstT = ", ShowFirst ), Color.WHITE);  #

#AddLabel(yes, Concat("ShowSecondT = ", ShowSecond ), Color.WHITE);#

#AddLabel(yes, Concat("ShowThirdT = ", ShowThird ), Color.WHITE);  #

#AddLabel(yes, Concat("ShowLabel = ", showLabel ), Color.WHITE);       #

#AddLabel(yes, Concat("TurnAlertOff = ", TurnAlertOff ), Color.WHITE); #

#AddLabel(yes, Concat("ThreeShows = ", ThreeShows_1), Color.WHITE); 

##########################################################



##### 2 ################ InvertedHammer() #################################

def ThreeShows_2 = If (ShowFirst == ShowFirst.InvertedHammer_2 or ShowSecond == ShowSecond.InvertedHammer_2 or ShowThird == ShowThird.InvertedHammer_2, 1, 0);

rec InvertedHammer_Trig = If(InvertedHammer().bullish , BarNumber(), InvertedHammer_Trig[1]);



AddLabel(InvertedHammer_Trig > 0  && showLabel  && ThreeShows_2, "2=InvertedHammer", Color.GREEN);

Alert(InvertedHammer() && !TurnAlertOff, "InvertedHammer Alert", Alert.BAR, Sound.Chimes);

AddChartBubble(InvertedHammer() && (BubVerb or BubNumb) && ThreeShows_2, low ,  if BubNumb

then "2"

else if BubVerb

then "InvertedHammer"

 else "" ,

  Color.WHITE , no);



##### 3 ################ ThreeOutsideUp() ###############################

def ThreeShows_3 = If (ShowFirst == ShowFirst.ThreeOutsideUp_3 or ShowSecond == ShowSecond.ThreeOutsideUp_3 or ShowThird == ShowThird.ThreeOutsideUp_3, 1, 0);

rec ThreeOutsideUp_Trig = If(ThreeOutsideUp().bullish , BarNumber(), ThreeOutsideUp_Trig[1]);



AddLabel(ThreeOutsideUp_Trig > 0  && showLabel  && ThreeShows_3, "3=ThreeOutsideUp", Color.GREEN);

Alert(ThreeOutsideUp() && !TurnAlertOff, "ThreeOutsideUp Alert", Alert.BAR, Sound.Chimes);

AddChartBubble(ThreeOutsideUp() && (BubVerb or BubNumb) && ThreeShows_3, low ,  if BubNumb

then "3"

else if BubVerb

then "ThreeOutsideUp"

 else "" ,

  Color.WHITE , no);

####### 4 ############## ThreeInsideUp() ###########################

def ThreeShows_4 = If (ShowFirst == ShowFirst.ThreeInsideUp_4 or ShowSecond == ShowSecond.ThreeInsideUp_4 or ShowThird == ShowThird.ThreeInsideUp_4, 1, 0);

rec ThreeInsideUp_Trig = If(ThreeInsideUp().bullish , BarNumber(), ThreeInsideUp_Trig[1]);



AddLabel(ThreeInsideUp_Trig > 0  && showLabel  && ThreeShows_4, "4=ThreeInsideUp", Color.GREEN);

Alert(ThreeInsideUp() && !TurnAlertOff, "ThreeInsideUp Alert", Alert.BAR, Sound.Chimes);

AddChartBubble(ThreeInsideUp() && (BubVerb or BubNumb) && ThreeShows_4 , low ,  if BubNumb

then "4"

else if BubVerb

then "ThreeInsideUp"

 else "" ,

  Color.WHITE , no);



###### 5 ############### PiercingLine() ###########################

def ThreeShows_5 = If (ShowFirst == ShowFirst.PiercingLine_5 or ShowSecond == ShowSecond.PiercingLine_5 or ShowThird == ShowThird.PiercingLine_5, 1, 0);

rec PiercingLine_Trig = If(PiercingLine().bullish , BarNumber(), PiercingLine_Trig[1]);



AddLabel(PiercingLine_Trig > 0  && showLabel  && ThreeShows_5, "5=PiercingLine", Color.GREEN);

Alert(PiercingLine() && !TurnAlertOff, "PiercingLine Alert", Alert.BAR, Sound.Chimes);

AddChartBubble(PiercingLine() && (BubVerb or BubNumb) && ThreeShows_5 , low ,  if BubNumb

then "5"

else if BubVerb

then "PiercingLine"

 else "" ,

  Color.WHITE , no);



###### 6 ############### ThreeWhiteSoldiers()  #######################

def ThreeShows_6 = If (ShowFirst == ShowFirst.ThreeWhiteSoldiers_6 or ShowSecond == ShowSecond.ThreeWhiteSoldiers_6 or ShowThird == ShowThird.ThreeWhiteSoldiers_6, 1, 0);

rec ThreeWhiteSoldiers_Trig = If(ThreeWhiteSoldiers().bullish , BarNumber(), ThreeWhiteSoldiers_Trig[1]);

AddLabel(ThreeWhiteSoldiers_Trig > 0  && showLabel  && ThreeShows_6, "6=ThreeWhiteSoldiers", Color.GREEN);

Alert(ThreeWhiteSoldiers() && !TurnAlertOff, "ThreeWhiteSoldiers Alert", Alert.BAR, Sound.Chimes);

AddChartBubble(ThreeWhiteSoldiers() && (BubVerb or BubNumb) && ThreeShows_6 , low ,  if BubNumb

then "6"

else if BubVerb

then "ThreeWhiteSoldiers"

 else "" ,

  Color.WHITE , no);



####### 7 ############## MorningDojiStar() ###########################

def ThreeShows_7 = If (ShowFirst == ShowFirst.MorningDojiStar_7 or ShowSecond == ShowSecond.MorningDojiStar_7 or ShowThird == ShowThird.MorningDojiStar_7, 1, 0);

rec MorningDojiStar_Trig = If(MorningDojiStar().bullish , BarNumber(), MorningDojiStar_Trig[1]);



AddLabel(MorningDojiStar_Trig > 0  && showLabel  && ThreeShows_7,  "7=MorningDojiStar", Color.GREEN);

Alert(MorningDojiStar() && !TurnAlertOff, "MorningDojiStar Alert", Alert.BAR, Sound.Chimes);

AddChartBubble(MorningDojiStar() && (BubVerb or BubNumb) && ThreeShows_7 , low ,  if BubNumb

then "7"

else if BubVerb

then "MorningDojiStar"

 else "" ,

  Color.WHITE , no);



####### 8 ############## ConcealingBabySwallow() #######################

def ThreeShows_8 = If (ShowFirst == ShowFirst.ConcealingBabySwallow_8 or ShowSecond == ShowSecond.ConcealingBabySwallow_8 or ShowThird == ShowThird.ConcealingBabySwallow_8, 1, 0);

rec ConcealingBabySwallow_Trig = If(ConcealingBabySwallow().bullish , BarNumber(), ConcealingBabySwallow_Trig[1]);



AddLabel(ConcealingBabySwallow_Trig > 0  && showLabel  && ThreeShows_8,  "8=ConcealingBabySwallow", Color.GREEN);

Alert(ConcealingBabySwallow() && !TurnAlertOff, "ConcealingBabySwallow Alert", Alert.BAR, Sound.Chimes);

AddChartBubble(ConcealingBabySwallow() && (BubVerb or BubNumb) && ThreeShows_8, low ,  if BubNumb

then "8"

else if BubVerb

then "ConcealingBabySwallow"

 else "" ,

  Color.WHITE , no);





######## 9 ############# HighPriceGappingPlay() #####################

def ThreeShows_9 = If (ShowFirst == ShowFirst.HighPriceGappingPlay_9 or ShowSecond == ShowSecond.HighPriceGappingPlay_9 or ShowThird == ShowThird.HighPriceGappingPlay_9, 1, 0);

rec HighPriceGappingPlay_Trig = If(HighPriceGappingPlay().bullish , BarNumber(), HighPriceGappingPlay_Trig[1]);



AddLabel(HighPriceGappingPlay_Trig > 0  && showLabel  && ThreeShows_9, "9=HighPriceGappingPlay", Color.GREEN);

Alert(HighPriceGappingPlay() && !TurnAlertOff, "HighPriceGappingPlay Alert", Alert.BAR, Sound.Chimes);

AddChartBubble(HighPriceGappingPlay() && (BubVerb or BubNumb) && ThreeShows_9 , low ,  if BubNumb

then "9"

else if BubVerb

then "HighPriceGappingPlay"

 else "" ,

  Color.WHITE , no);



######## 10 ############# HomingPigeon() ###########################

def ThreeShows_10 = If (ShowFirst == ShowFirst.HomingPigeon_10 or ShowSecond == ShowSecond.HomingPigeon_10 or ShowThird == ShowThird.HomingPigeon_10, 1, 0);

rec HomingPigeon_Trig = If(HomingPigeon().bullish , BarNumber(), HomingPigeon_Trig[1]);



AddLabel(HomingPigeon_Trig > 0  && showLabel  && ThreeShows_10, "10=HomingPigeon", Color.GREEN);

Alert(HomingPigeon() && !TurnAlertOff, "HomingPigeon Alert", Alert.BAR, Sound.Chimes);

AddChartBubble(HomingPigeon() && (BubVerb or BubNumb) && ThreeShows_10 , low ,  if BubNumb

then "10"

else if BubVerb

then "HomingPigeon"

 else "" ,

  Color.WHITE , no);

####### 11 ############## MatchingLow() ###########################

def ThreeShows_11 = If (ShowFirst == ShowFirst.MatchingLow_11 or ShowSecond == ShowSecond.MatchingLow_11 or ShowThird == ShowThird.MatchingLow_11, 1, 0);

rec MatchingLow_Trig = If(MatchingLow().bullish , BarNumber(), MatchingLow_Trig[1]);



AddLabel(MatchingLow_Trig > 0  && showLabel  && ThreeShows_11, "11=MatchingLow", Color.GREEN);

Alert(MatchingLow() && !TurnAlertOff, "MatchingLow Alert", Alert.BAR, Sound.Chimes);

AddChartBubble(MatchingLow() && (BubVerb or BubNumb) && ThreeShows_11 , low ,  if BubNumb

then "11"

else if BubVerb

then "MatchingLow"

 else "" ,

  Color.WHITE , no);

####### 12 ############## MatHold() ###########################

def ThreeShows_12 = If (ShowFirst == ShowFirst.MatHold_12 or ShowSecond == ShowSecond.MatHold_12 or ShowThird == ShowThird.MatHold_12, 1, 0);

rec MatHold_Trig = If(MatHold().bullish , BarNumber(), MatHold_Trig[1]);



AddLabel(MatHold_Trig > 0  && showLabel  && ThreeShows_12,  "12=MatHold", Color.GREEN);

Alert(MatHold() && !TurnAlertOff, "MatHold Alert", Alert.BAR, Sound.Chimes);

AddChartBubble(MatHold() && (BubVerb or BubNumb) && ThreeShows_12 , low ,  if BubNumb

then "12"

else if BubVerb

then "MatHold"

 else "" ,

  Color.WHITE , no);





####### 13 ############## MorningStar()###########################

def ThreeShows_13 = If (ShowFirst == ShowFirst.MorningStar_13 or ShowSecond == ShowSecond.MorningStar_13 or ShowThird == ShowThird.MorningStar_13, 1, 0);

rec MorningStar_Trig = If(MorningStar().bullish , BarNumber(), MorningStar_Trig[1]);



AddLabel(MorningStar_Trig > 0  && showLabel  && ThreeShows_13, "13=MorningStar", Color.GREEN);

Alert(MorningStar() && !TurnAlertOff, "MorningStar Alert", Alert.BAR, Sound.Chimes);

AddChartBubble(MorningStar() && (BubVerb or BubNumb) && ThreeShows_13 , low ,  if BubNumb

then "13"

else if BubVerb

then "MorningStar"

 else "" ,

  Color.WHITE , no);





####### 14 ############### RisingThreeMethods()#########################

def ThreeShows_14 = If (ShowFirst == ShowFirst.RisingThreeMethods_14 or ShowSecond == ShowSecond.RisingThreeMethods_14 or ShowThird == ShowThird.RisingThreeMethods_14, 1, 0);

rec RisingThreeMethods_Trig = If(RisingThreeMethods().bullish , BarNumber(), RisingThreeMethods_Trig[1]);



AddLabel(RisingThreeMethods_Trig > 0  && showLabel  && ThreeShows_14, "14=RisingThreeMethods", Color.GREEN);

Alert(RisingThreeMethods() && !TurnAlertOff, "RisingThreeMethods Alert", Alert.BAR, Sound.Chimes);

AddChartBubble(RisingThreeMethods() && (BubVerb or BubNumb) && ThreeShows_14 , low ,  if BubNumb

then "14"

else if BubVerb

then "RisingThreeMethods"

 else "" ,

  Color.WHITE , no);





###### 15 ################ StickSandwich() ##########################

def ThreeShows_15 = If (ShowFirst == ShowFirst.StickSandwich_15 or ShowSecond == ShowSecond.StickSandwich_15 or ShowThird == ShowThird.StickSandwich_15, 1, 0);

rec StickSandwich_Trig = If(StickSandwich().bullish , BarNumber(), StickSandwich_Trig[1]);



AddLabel(StickSandwich_Trig > 0  && showLabel  && ThreeShows_15, "15=StickSandwich", Color.GREEN);

Alert(StickSandwich() && !TurnAlertOff, "StickSandwich Alert", Alert.BAR, Sound.Chimes);

AddChartBubble(StickSandwich() && (BubVerb or BubNumb) && ThreeShows_15 , low ,  if BubNumb

then "15"

else if BubVerb

then "StickSandwich"

 else "" ,

  Color.WHITE , no);



###### 16 ########## ThreeStarsInTheSouth() ############################

def ThreeShows_16 = If (ShowFirst == ShowFirst.ThreeStarsInTheSouth_16 or ShowSecond == ShowSecond.ThreeStarsInTheSouth_16 or ShowThird == ShowThird.ThreeStarsInTheSouth_16, 1, 0);

rec ThreeStarsInTheSouth_Trig = If(ThreeStarsInTheSouth().bullish , BarNumber(), ThreeStarsInTheSouth_Trig[1]);



AddLabel(ThreeStarsInTheSouth_Trig > 0  && showLabel  && ThreeShows_16, "16=ThreeStarsInTheSouth", Color.GREEN);

Alert(ThreeStarsInTheSouth() && !TurnAlertOff, "ThreeStarsInTheSouth Alert", Alert.BAR, Sound.Chimes);

AddChartBubble(ThreeStarsInTheSouth() && (BubVerb or BubNumb) && ThreeShows_16 , low ,  if BubNumb

then "16"

else if BubVerb

then "ThreeStarsInTheSouth"

 else "" ,

  Color.WHITE , no);

###### 17########## UniqueThreeRiverBottom() ############################

def ThreeShows_17 = If (ShowFirst == ShowFirst.UniqueThreeRiverBottom_17 or ShowSecond == ShowSecond.UniqueThreeRiverBottom_17 or ShowThird == ShowThird.UniqueThreeRiverBottom_17, 1, 0);

rec UniqueThreeRiverBottom_Trig = If(UniqueThreeRiverBottom().bullish , BarNumber(), UniqueThreeRiverBottom_Trig[1]);



AddLabel(UniqueThreeRiverBottom_Trig > 0  && showLabel  && ThreeShows_17,  "17=UniqueThreeRiverBottom", Color.GREEN);

Alert(UniqueThreeRiverBottom() && !TurnAlertOff, "UniqueThreeRiverBottom Alert", Alert.BAR, Sound.Chimes);

AddChartBubble(UniqueThreeRiverBottom() && (BubVerb or BubNumb) && ThreeShows_17 , low ,  if BubNumb

then "17"

else if BubVerb

then "UniqueThreeRiverBottom"

 else "" ,

  Color.WHITE , no);





###### 18 ########## UpsideGapThreeMethods() ############################



def ThreeShows_18 = If (ShowFirst == ShowFirst.UpsideGapThreeMethods_18 or ShowSecond == ShowSecond.UpsideGapThreeMethods_18 or ShowThird == ShowThird.UpsideGapThreeMethods_18, 1, 0);

rec UpsideGapThreeMethods_Trig = If(UpsideGapThreeMethods().bullish , BarNumber(), UpsideGapThreeMethods_Trig[1]);



AddLabel(UpsideGapThreeMethods_Trig > 0  && showLabel  && ThreeShows_18, "18=UpsideGapThreeMethods", Color.GREEN);

Alert(UpsideGapThreeMethods() && !TurnAlertOff, "UpsideGapThreeMethods Alert", Alert.BAR, Sound.Chimes);

AddChartBubble(UpsideGapThreeMethods() && (BubVerb or BubNumb) && ThreeShows_18 , low ,  if BubNumb

then "18"

else if BubVerb

then "UpsideGapThreeMethods"

 else "" ,

  Color.WHITE , no);



###### 19 ########## UpsideTasukiGap() ############################



def ThreeShows_19 = If (ShowFirst == ShowFirst.UpsideTasukiGap_19 or ShowSecond == ShowSecond.UpsideTasukiGap_19 or ShowThird == ShowThird.UpsideTasukiGap_19, 1, 0);

rec UpsideTasukiGap_Trig = If(UpsideTasukiGap().bullish , BarNumber(), UpsideTasukiGap_Trig[1]);



AddLabel(UpsideTasukiGap_Trig > 0  && showLabel  && ThreeShows_19, "19=UpsideTasukiGap", Color.GREEN);

Alert(UpsideTasukiGap() && !TurnAlertOff, "UpsideTasukiGap Alert", Alert.BAR, Sound.Chimes);

AddChartBubble(UpsideTasukiGap() && (BubVerb or BubNumb) && ThreeShows_19 , low ,  if BubNumb

then "19"

else if BubVerb

then "UpsideTasukiGap"

 else "" ,

  Color.WHITE , no);





#####################################################

############## Processing 'Show All' = yes #######################

#####################################################



##### 1 ################ Hammer() & showAll ##################

def  candleAll_41 = If(ShowAll == yes , Hammer(), Double.NaN);

plot Ham = candleAll_41;

Ham.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

Ham.SetDefaultColor(Color.GREEN);

Ham.SetLineWeight(5);

rec Hammer_Trig_41 = If (Hammer().bullish, + BarNumber(), Hammer_Trig_41[1] );



AddLabel(Hammer_Trig_41 > 0 && showLabel && ShowAll, "1=Hammer" , Color.GREEN);

Alert(Hammer()  && !TurnAlertOff && ShowAll, "Hammer", Alert.BAR, Sound.Chimes);

AddChartBubble(Hammer() && (BubVerb or BubNumb) && (ShowAll) , low ,  if BubNumb

then "1"

else if BubVerb

then "Hammer"

 else "" ,  Color.WHITE , no);



##### 2 ################ InvertedHammer() & showAll ################

def candleAll_42 =  If(ShowAll == yes , InvertedHammer(), Double.NaN);

plot IH = candleAll_42;

IH.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

IH.SetDefaultColor(Color.GREEN);

IH.SetLineWeight(5);



rec InvertedHammer_Trig_42 = If (InvertedHammer().bullish , + BarNumber(), InvertedHammer_Trig_42[1] );

AddLabel(InvertedHammer_Trig_42 > 0 && showLabel && ShowAll,  "2=InvertedHammer" , Color.GREEN);

Alert(InvertedHammer()  && !TurnAlertOff && ShowAll, "InvertedHammer", Alert.BAR, Sound.Chimes);

AddChartBubble(InvertedHammer() && (BubVerb or BubNumb) && (ShowAll) , low ,  if BubNumb

then "2"

else if BubVerb

then "InvertedHammer"

 else "" ,  Color.WHITE , no);

##### 3 ################ ThreeOutsideUp() & showAll ################

def candleAll_43 = If(ShowAll == yes , ThreeOutsideUp(), Double.NaN);

plot TOU = candleAll_43;

TOU.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

TOU.SetDefaultColor(Color.GREEN);

TOU.SetLineWeight(5);



rec ThreeOutsideUp_Trig_43 = If (ThreeOutsideUp().bullish, + BarNumber(), ThreeOutsideUp_Trig_43[1] );

AddLabel(ThreeOutsideUp_Trig_43 > 0 && showLabel && ShowAll, "3=ThreeOutsideUp" , Color.GREEN);

Alert(ThreeOutsideUp()  && !TurnAlertOff && ShowAll, "ThreeOutsideUp", Alert.BAR, Sound.Chimes);

AddChartBubble(ThreeOutsideUp() && (BubVerb or BubNumb) && (ShowAll) , low ,  if BubNumb

then "3"

else if BubVerb

then "ThreeOutsideUp"

 else "" ,  Color.WHITE , no);

#AddChartLabel(yes, concat("Trig value =  ", ThreeOutsideUp_Trig_43), color.white);

#AddChartLabel(yes, concat("Total Bars =  ", + BarNumber()), color.white);

##### 4 ################ ThreeInsideUp() & showAll #################

def    candleAll_44 = If(ShowAll == yes , ThreeInsideUp(), Double.NaN);

plot TIU = candleAll_44;

TIU.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

TIU.SetDefaultColor(Color.GREEN);

TIU.SetLineWeight(5);



rec ThreeInsideUp_Trig_44 = If (ThreeInsideUp().bullish == yes , + BarNumber(), ThreeInsideUp_Trig_44[1] );

AddLabel(ThreeInsideUp_Trig_44 > 0 && showLabel && ShowAll, "4=ThreeInsideUp" , Color.GREEN);

Alert(ThreeInsideUp()  && !TurnAlertOff && ShowAll, "ThreeInsideUp", Alert.BAR, Sound.Chimes);

AddChartBubble(ThreeInsideUp() && (BubVerb or BubNumb) && (ShowAll) , low ,  if BubNumb

then "4"

else if BubVerb

then "ThreeInsideUp"

 else "" ,  Color.WHITE , no);

##### 5 ################ PiercingLine() & showAll ######################

def    candleAll_45 = If(ShowAll == yes  , PiercingLine(), Double.NaN);

plot PL = candleAll_45;

PL.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

PL.SetDefaultColor(Color.GREEN);

PL.SetLineWeight(5);



rec PiercingLine_Trig_45 = If (PiercingLine().bullish == yes , + BarNumber(), PiercingLine_Trig_45[1] );

AddLabel(PiercingLine_Trig_45 > 0 && showLabel && ShowAll, "5=PiercingLine" , Color.GREEN);

Alert(PiercingLine()  && !TurnAlertOff && ShowAll, "PiercingLine", Alert.BAR, Sound.Chimes);

AddChartBubble(PiercingLine() && (BubVerb or BubNumb) && (ShowAll) , low ,  if BubNumb

then "5"

else if BubVerb

then "PiercingLine"

 else "" ,  Color.WHITE , no);



##### 6 ################ ThreeWhiteSoldiers() & showAll ##################

def    candleAll_46 = If(ShowAll == yes, ThreeWhiteSoldiers(), Double.NaN);

plot TWS = candleAll_46;

TWS.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

TWS.SetDefaultColor(Color.GREEN);

TWS.SetLineWeight(5);



rec ThreeWhiteSoldiers_Trig_46 = If (ThreeWhiteSoldiers().bullish == yes , + BarNumber(), ThreeWhiteSoldiers_Trig_46[1] );

AddLabel(ThreeWhiteSoldiers_Trig_46 > 0 && showLabel && ShowAll, "6=ThreeWhiteSoldiers" , Color.GREEN);

Alert(ThreeWhiteSoldiers()  && !TurnAlertOff && ShowAll, "ThreeWhiteSoldiers", Alert.BAR, Sound.Chimes);

AddChartBubble(ThreeWhiteSoldiers() && (BubVerb or BubNumb) && (ShowAll) , low ,  if BubNumb

then "6"

else if BubVerb

then "ThreeWhiteSoldiers"

 else "" ,  Color.WHITE , no);



##### 7 ################ MorningDojiStar() & showAll ######################

def    candleAll_47 = If(ShowAll == yes  , MorningDojiStar(), Double.NaN);

plot MDS = candleAll_47;

MDS.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

MDS.SetDefaultColor(Color.GREEN);

MDS.SetLineWeight(5);





rec MorningDojiStar_Trig_47 = If (MorningDojiStar().bullish == yes , + BarNumber(), MorningDojiStar_Trig_47[1] );

AddLabel(MorningDojiStar_Trig_47 > 0 && showLabel && ShowAll, "7=MorningDojiStar" , Color.GREEN);

Alert(MorningDojiStar()  && !TurnAlertOff && ShowAll, "MorningDojiStar", Alert.BAR, Sound.Chimes);

AddChartBubble(MorningDojiStar() && (BubVerb or BubNumb) && (ShowAll) , low ,  if BubNumb

then "7"

else if BubVerb

then "MorningDojiStar"

 else "" ,  Color.WHITE , no);



##### 8  ########### ConcealingBabySwallow() & showAll ###################

def candleAll_48 = If(ShowAll == yes , ConcealingBabySwallow(), Double.NaN);

plot CBS = candleAll_48;

CBS.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

CBS.SetDefaultColor(Color.GREEN);

CBS.SetLineWeight(5);



rec ConcealingBabySwallow_Trig_48 = If (ConcealingBabySwallow().bullish == yes , + BarNumber(), ConcealingBabySwallow_Trig_48[1] );

AddLabel(ConcealingBabySwallow_Trig_48 > 0 && showLabel && ShowAll, "8=ConcealingBabySwallow" , Color.GREEN);

Alert(ConcealingBabySwallow()  && !TurnAlertOff && ShowAll, "ConcealingBabySwallow", Alert.BAR, Sound.Chimes);

AddChartBubble(ConcealingBabySwallow() && (BubVerb or BubNumb) && (ShowAll) , low ,  if BubNumb

then "8"

else if BubVerb

then "ConcealingBabySwallow"

 else "" ,  Color.WHITE , no);



#####  9 ########### HighPriceGappingPlay() & showAll #####################

def candleAll_49 = If(ShowAll == yes , HighPriceGappingPlay(), Double.NaN);

plot HPGP = candleAll_49;

HPGP.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

HPGP.SetDefaultColor(Color.GREEN);

HPGP.SetLineWeight(5);



rec HighPriceGappingPlay_Trig_49 = If (HighPriceGappingPlay().bullish == yes , + BarNumber(), HighPriceGappingPlay_Trig_49[1] );

AddLabel(HighPriceGappingPlay_Trig_49 > 0 && showLabel && ShowAll, "9=HighPriceGappingPlay" , Color.GREEN);

Alert(HighPriceGappingPlay()  && !TurnAlertOff && ShowAll, "HighPriceGappingPlay", Alert.BAR, Sound.Chimes);

AddChartBubble(HighPriceGappingPlay() && (BubVerb or BubNumb) && (ShowAll) , low ,  if BubNumb

then "9"

else if BubVerb

then "HighPriceGappingPlay"

 else "" ,  Color.WHITE , no);



##### 10  ################ HomingPigeon() & showAll #################

def candleAll_50 = If(ShowAll == yes  , HomingPigeon(), Double.NaN);

plot HP = candleAll_50;

HP.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

HP.SetDefaultColor(Color.GREEN);

HP.SetLineWeight(5);



rec HomingPigeon_Trig_50 = If (HomingPigeon().bullish == yes , + BarNumber(),HomingPigeon_Trig_50[1] );

AddLabel(HomingPigeon_Trig_50 > 0 && showLabel && ShowAll, "10=HomingPigeon" , Color.GREEN);

Alert(HomingPigeon()  && !TurnAlertOff && ShowAll, "HomingPigeon", Alert.BAR, Sound.Chimes);

AddChartBubble(HomingPigeon() && (BubVerb or BubNumb) && (ShowAll) , low ,  if BubNumb

then "10"

else if BubVerb

then "HomingPigeon"

 else "" ,  Color.WHITE , no);



#AddChartLabel(yes, concat("Trig value =  ", HomingPigeon_Trig_50), color.white);

#AddChartLabel(yes, concat("Total Bars =  ", + BarNumber()), color.white);

##### 11 ################ MatchingLow() & showAll #################

def candleAll_51 = If(ShowAll == yes , MatchingLow(), Double.NaN);

plot ML = candleAll_51;

ML.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

ML.SetDefaultColor(Color.GREEN);

ML.SetLineWeight(5);



rec MatchingLow_Trig_51 = If (MatchingLow().bullish == yes , + BarNumber(), MatchingLow_Trig_51[1] );

AddLabel(MatchingLow_Trig_51 > 0 && showLabel && ShowAll, "11=MatchingLow" , Color.GREEN);

Alert(MatchingLow()  && !TurnAlertOff && ShowAll, "MatchingLow", Alert.BAR, Sound.Chimes);

AddChartBubble(MatchingLow() && (BubVerb or BubNumb) && (ShowAll) , low ,  if BubNumb

then "11"

else if BubVerb

then "MatchingLow"

 else "" ,  Color.WHITE , no);



##### 12 ################ MatHold() & showAll ##################

def candleAll_52 = If(ShowAll == yes  , MatHold(), Double.NaN);

plot MH = candleAll_52;

MH.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

MH.SetDefaultColor(Color.GREEN);

MH.SetLineWeight(5);



rec MatHold_Trig_52 = If (MatHold().bullish == yes , + BarNumber(), MatHold_Trig_52[1] );

AddLabel(MatHold_Trig_52 > 0 && showLabel && ShowAll, "12=MatHold" , Color.GREEN);

Alert(MatHold()  && !TurnAlertOff && ShowAll, "MatHold", Alert.BAR, Sound.Chimes);

AddChartBubble(MatHold() && (BubVerb or BubNumb) && (ShowAll) , low ,  if BubNumb

then "12"

else if BubVerb

then "MatHold"

 else "" ,  Color.WHITE , no);



##### 13  ################ MorningStar() & showAll ################

def candleAll_53 = If(ShowAll == yes , MorningStar(), Double.NaN);

plot MS = candleAll_53;

MS.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

MS.SetDefaultColor(Color.GREEN);

MS.SetLineWeight(5);



rec MorningStar_Trig_53 = If (MorningStar().bullish == yes , + BarNumber(), MorningStar_Trig_53[1] );

AddLabel(MorningStar_Trig_53 > 0 && showLabel && ShowAll, "13=MorningStar" , Color.GREEN);

Alert(MorningStar()  && !TurnAlertOff && ShowAll, "MorningStar", Alert.BAR, Sound.Chimes);

AddChartBubble(MorningStar() && (BubVerb or BubNumb) && (ShowAll) , low ,  if BubNumb

then "13"

else if BubVerb

then "MorningStar"

 else "" ,  Color.WHITE , no);



##### 14 ########## RisingThreeMethods() & showAll ####################

def candleAll_54 = If(ShowAll == yes  , RisingThreeMethods(), Double.NaN);

plot RTM = candleAll_54;

RTM.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

RTM.SetDefaultColor(Color.GREEN);

RTM.SetLineWeight(5);



rec RisingThreeMethods_Trig_54 = If (RisingThreeMethods().bullish == yes , + BarNumber(), RisingThreeMethods_Trig_54[1] );

AddLabel(RisingThreeMethods_Trig_54 > 0 && showLabel && ShowAll, "14=RisingThreeMethods" , Color.GREEN);

Alert(RisingThreeMethods()  && !TurnAlertOff && ShowAll, "RisingThreeMethods", Alert.BAR, Sound.Chimes);

AddChartBubble(RisingThreeMethods() && (BubVerb or BubNumb) && (ShowAll) , low ,  if BubNumb

then "14"

else if BubVerb

then "RisingThreeMethods"

 else "" ,  Color.WHITE , no);



##### 15  ################ StickSandwich() & showAll ################

def candleAll_55 = If(ShowAll == yes , StickSandwich(), Double.NaN);

plot SS = candleAll_55;

SS.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

SS.SetDefaultColor(Color.GREEN);

SS.SetLineWeight(5);



rec StickSandwich_Trig_55 = If (StickSandwich().bullish == yes , + BarNumber(), StickSandwich_Trig_55[1] );

AddLabel(StickSandwich_Trig_55 > 0 && showLabel && ShowAll,  "15=StickSandwich" , Color.GREEN);

Alert(StickSandwich()  && !TurnAlertOff && ShowAll, "StickSandwich", Alert.BAR, Sound.Chimes);

AddChartBubble(StickSandwich() && (BubVerb or BubNumb) && (ShowAll) , low ,  if BubNumb

then "15"

else if BubVerb

then "StickSandwich"

 else "" ,  Color.WHITE , no);



##### 16 ########### ThreeStarsInTheSouth() & showAll ##############

def candleAll_56 = If(ShowAll == yes , ThreeStarsInTheSouth(), Double.NaN);

plot TSITS = candleAll_56;

TSITS.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

TSITS.SetDefaultColor(Color.GREEN);

TSITS.SetLineWeight(5);



rec ThreeStarsInTheSouth_Trig_56 = If (ThreeStarsInTheSouth().bullish == yes , + BarNumber(), ThreeStarsInTheSouth_Trig_56[1] );

AddLabel(ThreeStarsInTheSouth_Trig_56 > 0 && showLabel && ShowAll, "16=ThreeStarsInTheSouth" , Color.GREEN);

Alert(ThreeStarsInTheSouth()  && !TurnAlertOff && ShowAll, "ThreeStarsInTheSouth", Alert.BAR, Sound.Chimes);

AddChartBubble(ThreeStarsInTheSouth() && (BubVerb or BubNumb) && (ShowAll) , low ,  if BubNumb

then "16"

else if BubVerb

then "ThreeStarsInTheSouth"

 else "" ,  Color.WHITE , no);



##### 17  ######### UniqueThreeRiverBottom() & showAll #############

def candleAll_57 = If(ShowAll == yes, UniqueThreeRiverBottom(), Double.NaN);

plot UTRB = candleAll_57;

UTRB.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

UTRB.SetDefaultColor(Color.GREEN);

UTRB.SetLineWeight(5);



rec UniqueThreeRiverBottom_Trig_57 = If (UniqueThreeRiverBottom().bullish == yes , + BarNumber(), UniqueThreeRiverBottom_Trig_57[1] );

AddLabel(UniqueThreeRiverBottom_Trig_57 > 0 && showLabel && ShowAll, "17=UniqueThreeRiverBottom" , Color.GREEN);

Alert(UniqueThreeRiverBottom()  && !TurnAlertOff && ShowAll, "UniqueThreeRiverBottom", Alert.BAR, Sound.Chimes);

AddChartBubble(UniqueThreeRiverBottom() && (BubVerb or BubNumb) && (ShowAll) , low ,  if BubNumb

then "17"

else if BubVerb

then "UniqueThreeRiverBottom"

 else "" ,  Color.WHITE , no);



##### 18 ########## UpsideGapThreeMethods() & showAll ############

def candleAll_58 = If(ShowAll == yes , UpsideGapThreeMethods(), Double.NaN);

plot UGTM = candleAll_58;

UGTM.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

UGTM.SetDefaultColor(Color.GREEN);

UGTM.SetLineWeight(5);



rec UpsideGapThreeMethods_Trig_58 =  If (UpsideGapThreeMethods().bullish == yes , + BarNumber(), UpsideGapThreeMethods_Trig_58[1]);

AddLabel(UpsideGapThreeMethods_Trig_58 > 0 && showLabel && ShowAll, "18=UpsideGapThreeMethods" , Color.GREEN);

Alert(UpsideGapThreeMethods()  && !TurnAlertOff && ShowAll, "UpsideGapThreeMethods", Alert.BAR, Sound.Chimes);

AddChartBubble(UpsideGapThreeMethods() && (BubVerb or BubNumb) && (ShowAll) , low ,  if BubNumb

then "18"

else if BubVerb

then "UpsideGapThreeMethods"

 else "" ,  Color.WHITE , no);



##### 19  ################ UpsideTasukiGap() & showAll #################

def    candleAll_59 = If(ShowAll == yes  , UpsideTasukiGap(), Double.NaN);

plot UTG = candleAll_59;

UTG.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);

UTG.SetDefaultColor(Color.GREEN);

UTG.SetLineWeight(5);



rec UpsideTasukiGap_Trig_59 = If (UpsideTasukiGap().bullish == yes , + BarNumber(), UpsideTasukiGap_Trig_59[1] );

AddLabel(UpsideTasukiGap_Trig_59 > 0 && showLabel && ShowAll, "19=UpsideTasukiGap" , Color.GREEN);

Alert(UpsideTasukiGap()  && !TurnAlertOff && ShowAll, "UpsideTasukiGap", Alert.BAR, Sound.Chimes);

AddChartBubble(UpsideTasukiGap() && (BubVerb or BubNumb) && (ShowAll) , low ,  if BubNumb

then "19"

else if BubVerb

then "UpsideTasukiGap"

 else "" ,  Color.WHITE , no);

##########################################################

#################### End of showAll processing  ######################

##########################################################

Shareable Link

https://tos.mx/Ek9jOd
 
Last edited:

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

Thanks for this awesome script. Can you modify the code so it shows only these three : hammer, pinbar, and doji and that it does NOT change the candle/background color
 
@BenTen Thanks for the script. How can this converted into a scan? Specifically I am looking to create scan for bullish candlestick patterns on a weekly chart (end of week) which can be searched for a given time period (lets say last x weeks)? Thanks
 
@BenTen Thanks for the script. How can this converted into a scan? Specifically I am looking to create scan for bullish candlestick patterns on a weekly chart (end of week) which can be searched for a given time period (lets say last x weeks)? Thanks
The script is too complex for the ToS scan hacker.
You can go into pattern maker and scan for each bullish pattern individually.
https://tlc.thinkorswim.com/center/...tock-Hacker#:~:text=To adjust a,be looked for.
 
I pair this with Super T Rev and i turn the candle painting off on the Super T script, and watch for OB OS in B4 column watchlist

#----------------------------------------
#Bullish Candle - Typical Bullish Candles
#----------------------------------------

input length3 = 10;
def GreenCandle =
IsLongWhite(length3);
plot Bullish = GreenCandle;

#----------------------------------------------------------
#Spinning Top - Immediately preceding trend losing momemtum
#----------------------------------------------------------

def body_top = Max(open, close);
def body_bottom = Min(open, close);
def upper_shadow = high - body_top;
def lower_shadow = body_bottom - low;
def candle_height = high - low;

def body_height_is_less_than_one_third_candle_height = candle_height > 3 * BodyHeight();
def upper_shadow_height_is_less_than_one_half_ish_candle_height = upper_shadow < (.001 + candle_height) / 2;
def lower_shadow_height_is_less_than_one_half_ish_candle_height = lower_shadow < (.001 + candle_height) / 2;

def smallbody = body_height_is_less_than_one_third_candle_height
and upper_shadow_height_is_less_than_one_half_ish_candle_height
and lower_shadow_height_is_less_than_one_half_ish_candle_height;

plot Spinning_Top = smallbody;

#-----------------------------------------------------------------------------------------
#Doji - Market is at a point of indecision. Highest high of doji and prior candle used for resistance. No support.
#-----------------------------------------------------------------------------------------

input length = 20;
input bodyFactor = 0.05;
Assert(bodyFactor >= 0, "'body factor' must not be negative: " + bodyFactor);
def Doji = IsDoji(length, bodyFactor);

plot DojiR = if Doji and high < high[1] then high[1] else if Doji and high >= high[1] then high else Double.NaN;
DojiR.SetPaintingStrategy(PaintingStrategy.DASHES);
DojiR.SetDefaultColor(Color.RED);
DojiR.SetLineWeight(2);

def DojiRext = if IsNaN(DojiR) then DojiRext[1] else DojiR;
plot DojiRextline = DojiRext;
DojiRextline.SetPaintingStrategy(PaintingStrategy.DASHES);
DojiRextline.SetDefaultColor(Color.RED);

#-------------------------------------------------------------------
#Inside Bar - Consolidation. There is a fight going on for direction
#-------------------------------------------------------------------

def IsUp = close > open;
def IsDown = close < open;
def IsDoji = IsDoji();
def avgRange = 0.05 * Average(high - low, 20);
def InsideBar =
((Sum(IsUp, 1)[1] >= 0)) and
((Sum(IsUp, 1)[0] >= 0)) and
Highest(high[1], 1) >= Highest(high[0], 1) and
Lowest(low[1], 1) <= Lowest(low[0], 1);

#-------------------------------------------------------------------------------------------
# High Wave Candlestick Pattern - Market is "confused." You do not want to stay in the trade
# Assembled by BenTen at useThinkScript.com
#-------------------------------------------------------------------------------------------

def Day = (high - low);
def Day_1 = (high[1] - low[1]);
def Day_2 = (high[2] - low[2]);
def Day_3 = (high[3] - low[3]);
def Day_4 = (high[4] - low[4]);
def Day_5 = (high[5] - low[5]);
def Avg = ((Day_1 + Day_2 + Day_3 + Day_4 + Day_5) / 5);
input Highwave_Wick_Multiplier = 3.0;
input Range_Multiplier = 1.0;

def Highwave = (((high - low) - (AbsValue(open - close))) > ((AbsValue(open - close)) * Highwave_Wick_Multiplier)) and ((Day > (Avg * Range_Multiplier)));

#----------------------------------------------------------------------
#Hammer - "A chance to buy at the bottom." Use Low of hammer as Support
#----------------------------------------------------------------------

def MovingAvg = 52;
def Avg2 = SimpleMovingAvg(close, MovingAvg);
def CandleBody = AbsValue(open - close);
def UpperWick = high - Max(open, close);
def LowerWick = Min(open, close) – low;
def Hammer = LowerWick > CandleBody * 2 and UpperWick <= LowerWick * 0.2 and low < low[1] and low < low[2] and low < low[3] and low < low[4] and low < low[5] and low < low[6] and low < low[7] and low < low[8] and close > Avg;

plot Hammer2 = if Hammer then low else Double.NaN;
Hammer2.SetPaintingStrategy(PaintingStrategy.DASHES);
Hammer2.SetDefaultColor(Color.GREEN);
Hammer2.SetLineWeight(2);
def hammer2ext = if IsNaN(Hammer2) then hammer2ext[1] else Hammer2;
plot Hammer2extline = hammer2ext;
Hammer2extline.SetPaintingStrategy(PaintingStrategy.DASHES);
Hammer2extline.SetDefaultColor(Color.GREEN);

#----------------------------------------------------------
#Bullish Engulfing - A Bottom Reversal. The bullish candle wraps around the entire body of the previous candle in a downtrend. Lowest low of the two sessions is Support.
#----------------------------------------------------------

def BullEngulf =
IsDescending(close, 3)[2] and
IsDown[1] and
IsUp[0] and
open[1] < close[0] and
close[1] >= open[0];

plot BullSupport = if BullEngulf and low > low [1] then low[1] else if BullEngulf and low <= low[1] then low else Double.NaN;
BullSupport.SetPaintingStrategy(PaintingStrategy.DASHES);
BullSupport.SetDefaultColor(Color.DARK_ORANGE);
BullSupport.SetLineWeight(2);
def Bullext = if IsNaN(BullSupport) then Bullext[1] else BullSupport;
plot Bullextline = Bullext;
Bullextline.SetPaintingStrategy(PaintingStrategy.DASHES);
Bullextline.SetDefaultColor(Color.DARK_ORANGE);

#----------------------------------------------------------------------------------------------
#Bullish Harami - Market in a downtrend. First Candle is unusually Long Downward Candle. Second candle has a small body within the prior red candle body. Prior trend is "losing breathe."
#----------------------------------------------------------------------------------------------

input length1 = 20;
input trendSetup1 = 3;
input bodyFactor1 = 0.3;
Assert(bodyFactor1 >= 0, "'body factor' must not be negative: " + bodyFactor1);

def BodyHeight = BodyHeight();
def IsShort = BodyHeight < bodyFactor1 * Average(BodyHeight, length);
def BodyMax = Max(open, close);
def BodyMin = Min(open, close);
def IsEngulfing = BodyMax < BodyMax[1] and
BodyMin > BodyMin[1];

plot BullishHarami = IsDescending(close, trendSetup1)[1] and
IsLongBlack(length)[1] and
IsEngulfing and
IsShort;

BullishHarami.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
BullishHarami.SetDefaultColor(color.green);

#----------------------------------------
#Bearish Candles - Typical Bearish Candles
#----------------------------------------

input length4 = 10;
def RedCandles =
IsLongBlack(length4);
plot Bearish = RedCandles;

#-------------------------
#Bearish Engulfing Candle - A Top Reversal. The bearish candle wraps around the entire body of the previous candle in a uptrend. Highest High of the two sessions is Resistance.
#-------------------------

def BearEngulf =
IsAscending(close, 3)[2] and
IsUp[1] and
IsDown[0] and
close[1] < open[0] and
open[1] > close[0];
plot BResistance = if BearEngulf and high < high[1] then high[1] else if BearEngulf and high >= high[1] then high else Double.NaN;
BResistance.SetPaintingStrategy(PaintingStrategy.DASHES);
BResistance.SetDefaultColor(Color.DARK_ORANGE);
BResistance.SetLineWeight(2);

def BRext = if IsNaN(BResistance) then BRext[1] else BResistance;
plot BRextline = BRext;
BRextline.SetPaintingStrategy(PaintingStrategy.DASHES);
BRextline.SetDefaultColor(Color.DARK_ORANGE);

#-----------------------------------------------------------------------------------------------
#Piercing Line - Market in Downtrend. Candle opens below prior low and closes more than 50% into prior down candle. Lowest low of the two candles is Support.
#-----------------------------------------------------------------------------------------------

input length2 = 20;
input trendSetup = 3;

def PierceCandle = IsDescending(close, trendSetup)[1] and
IsLongBlack(length2)[1] and
open < low[1] and
close > MidBodyVal()[1] and
close < open[1];
def PiercingLine = PierceCandle;

plot PierceSupport = if PiercingLine and low > low [1] then low[1] else if PiercingLine and low <= low[1] then low else Double.NaN;
PierceSupport.SetPaintingStrategy(PaintingStrategy.DASHES);
PierceSupport.SetDefaultColor(Color.CYAN);
PierceSupport.SetLineWeight(2);
def Pext = if IsNaN(PierceSupport) then Pext[1] else PierceSupport;
plot Pextline = Pext;
Pextline.SetPaintingStrategy(PaintingStrategy.DASHES);
Pextline.SetDefaultColor(Color.CYAN);

#------------------
#Dark Cloud Covers - Market in Uptrend. Candle opens above prior high and closes more than 50% into prior high candle. Highest high of the two candles is Resistance.
#------------------

def CloudCandle = IsAscending(close, trendSetup)[1] and
IsLongWhite(length)[1] and
open > high[1] and
close < MidBodyVal()[1] and
close > open[1];
def DarkCloudCover = CloudCandle;

plot DResistance = if DarkCloudCover and high < high[1] then high[1] else if DarkCloudCover and high >= high[1] then high else Double.NaN;
DResistance.SetPaintingStrategy(PaintingStrategy.DASHES);
DResistance.SetDefaultColor(Color.CYAN);
DResistance.SetLineWeight(2);
def DRext = if IsNaN(DResistance) then DRext[1] else DResistance;
plot DRextline = DRext;
DRextline.SetPaintingStrategy(PaintingStrategy.DASHES);
DRextline.SetDefaultColor(Color.CYAN);

#--------------
#Bearish Harami - Market in a uptrend. First Candle is unusually Long Upward Candle. Second candle has a small body within the prior green candle body. Prior trend is "losing breathe."
#--------------
Assert(bodyFactor >= 0, "'body factor' must not be negative: " + bodyFactor);

def BodyHeight1 = BodyHeight();
def IsShort1 = BodyHeight < bodyFactor * Average(BodyHeight, length);
def BodyMax1 = Max(open, close);
def BodyMin1 = Min(open, close);
def IsEngulfing1 = BodyMax < BodyMax[1] and
BodyMin > BodyMin[1];

plot BearishHarami = IsAscending(close, trendSetup)[1] and
IsLongWhite(length)[1] and
IsEngulfing and
IsShort;

BearishHarami.SetPaintingStrategy(PaintingStrategy.BOOLEAN_wEDGE_DOWN);
BearishHarami.SetDefaultColor(color.Red);

#----------------------------------------------------------------------------------------------
#Shooting Star - Market in an uptrend. Small real body of candle at or near the bottom of range
#Upper shadow at least 2x height of body of candle
#----------------------------------------------------------------------------------------------

input Star_length = 30;
input Star_trendSetup = 3;
input Star_bodyFactor = 0.3;
input Star_shadowFactor = 2.0;

Assert(Star_bodyFactor >= 0, "'body factor' must not be negative: " + Star_bodyFactor);
Assert(Star_shadowFactor >= 0, "'shadow factor' must not be negative: " + Star_shadowFactor);

def Star_BodyHeight = BodyHeight();
def Star_AverageBodyHeight = Average(Star_BodyHeight, Star_length);
def Star_ErrMargin = 0.25 * Star_AverageBodyHeight;
def Star_IsShort = Star_BodyHeight <= Star_bodyFactor * Star_AverageBodyHeight;

def ShootingStar = IsAscending(close, Star_trendSetup)[1] and

Star_IsShort and
Min(open, close) - low <= Star_ErrMargin and
high - Max(open, close) > Star_shadowFactor * Star_BodyHeight;
plot SSR = if ShootingStar then high else Double.NaN;
SSR.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SSR.SetDefaultColor(Color.Red);
def SSRext = if IsNaN(SSR) then SSRext[1] else SSR;
plot SSRextline = SSRext;
SSRextline.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SSRextline.SetDefaultColor(Color.Red);

AssignPriceColor(if spinning_top then Color.BLUE else if Bullish then Color.GREEN else if Bearish then Color.RED else if BullEngulf or BearEngulf then Color.DARK_ORANGE else if Doji then Color.DARK_RED else if PiercingLine or DarkCloudCover then Color.CYAN else if Highwave then Color.PLUM else if InsideBar then Color.WHITE else if ShootingStar then Color.ORANGE else Color.CURRENT);
 
@BenTen Thanks for the script. How can this converted into a scan? Specifically I am looking to create scan for bullish candlestick patterns on a weekly chart (end of week) which can be searched for a given time period (lets say last x weeks)? Thanks
Hi. It may be an old request and one that remained unanswered, I still want to share the code for scanning and watchlist column (just saw this query). We use this whenever we train a new trader.

Three things though:
1. The coder had to divide the code into two parts since TOS prevents adding more than 11 patterns in one go (it deems it too complex beyond that).
2. It's better to use it as a watchlist column using an expansive watchlist since it's faster that way. When using it as a live scan, half of the time TOS won't even give a scan (or will reduce to a crawl).
3. As a watchlist column it will turn green whenever 1 of the 20 is triggered else remains gray.

PART 1 CODE

Code:
# Bullish Candlesticks as watchlist column (and scanner)
# Part 1 of 2
# Hint: As a watchlist column it will turn green whenever 1 of the 20 is triggered else remains gray.

############# Part 1 ##################################

def candle1 = If (yes, Hammer(), Double.NaN);

def candle2 = If (yes, InvertedHammer(), Double.NaN);

def candle3 =  If(yes, ThreeOutsideUp(), Double.NaN);

def candle4 =  If(yes, ThreeInsideUp(), Double.NaN);

def candle5 =  If(yes, PiercingLine(), Double.NaN);

def candle6 =  If(yes, ThreeWhiteSoldiers(), Double.NaN);

def candle7 =  If(yes, MorningDojiStar(), Double.NaN);

def candle8 =  If(yes, ConcealingBabySwallow(), Double.NaN);

def candle9 =  If(yes, HighPriceGappingPlay(), Double.NaN);

def candle10 =  If(yes, HomingPigeon(), Double.NaN);


############# Part 2 ###################################

# def candle11 =  If(yes, MatchingLow(), Double.NaN);

# def candle12 =  If(yes, MatHold(), Double.NaN);

# def candle13 =  If(yes, MorningStar(), Double.NaN);

# def candle14 =  If(yes, RisingThreeMethods(), Double.NaN);

# def candle15 =  If(yes, StickSandwich(), Double.NaN);

# def candle16 =  If(yes, ThreeStarsInTheSouth(), Double.NaN);

# def candle17 =  If(yes, UniqueThreeRiverBottom(), Double.NaN);

# def candle18 =  If(yes, UpsideGapThreeMethods(), Double.NaN);

# def candle19 =  If(yes, UpsideTasukiGap(), Double.NaN);

# def candle20 =  If(yes, OneWhiteSoldierWhiteSoldiers(), Double.NaN);


plot Triggered = if (candle1 or candle2 or candle3 or candle4 or candle5 or candle6 or candle7 or candle8 or candle9 or candle10) is true then 1 else 0;


# Truncate the two lines below before using as a scan

Triggered.AssignValueColor(if Triggered == 1 then Color.GREEN else Color.GRAY);

AssignBackgroundColor(if Triggered == 1 then Color.GREEN else Color.GRAY);



PART 2 CODE


Code:
# Bullish Candlesticks as watchlist column (and scanner)
# Part 2 of 2
# Hint: As a watchlist column it will turn green whenever 1 of the 20 is triggered else remains gray.


############# Part 1 ##################################

# def candle1 = If (yes, Hammer(), Double.NaN);

# def candle2 = If (yes, InvertedHammer(), Double.NaN);

# def candle3 =  If(yes, ThreeOutsideUp(), Double.NaN);

# def candle4 =  If(yes, ThreeInsideUp(), Double.NaN);

# def candle5 =  If(yes, PiercingLine(), Double.NaN);

# def candle6 =  If(yes, ThreeWhiteSoldiers(), Double.NaN);

# def candle7 =  If(yes, MorningDojiStar(), Double.NaN);

# def candle8 =  If(yes, ConcealingBabySwallow(), Double.NaN);

# def candle9 =  If(yes, HighPriceGappingPlay(), Double.NaN);

# def candle10 =  If(yes, HomingPigeon(), Double.NaN);


 

############# Part 2 ###################################

def candle11 =  If(yes, MatchingLow(), Double.NaN);

def candle12 =  If(yes, MatHold(), Double.NaN);

def candle13 =  If(yes, MorningStar(), Double.NaN);

def candle14 =  If(yes, RisingThreeMethods(), Double.NaN);

def candle15 =  If(yes, StickSandwich(), Double.NaN);

def candle16 =  If(yes, ThreeStarsInTheSouth(), Double.NaN);

def candle17 =  If(yes, UniqueThreeRiverBottom(), Double.NaN);

def candle18 =  If(yes, UpsideGapThreeMethods(), Double.NaN);

def candle19 =  If(yes, UpsideTasukiGap(), Double.NaN);

def candle20 =  If(yes, OneWhiteSoldier(), Double.NaN);


plot Triggered = if (candle11 or candle12 or candle13 or candle14 or candle15 or candle16 or candle17 or candle18 or candle19 or candle20) is true then 1 else 0;


# Truncate the two lines below before using as a scan

Triggered.AssignValueColor(if Triggered == 1 then Color.GREEN else Color.GRAY);

AssignBackgroundColor(if Triggered == 1 then Color.GREEN else Color.GRAY);





FXdXsJ3.png
 
I pair this with Super T Rev and i turn the candle painting off on the Super T script, and watch for OB OS in B4 column watchlist

#----------------------------------------
#Bullish Candle - Typical Bullish Candles
#----------------------------------------

input length3 = 10;
def GreenCandle =
IsLongWhite(length3);
plot Bullish = GreenCandle;

#----------------------------------------------------------
#Spinning Top - Immediately preceding trend losing momemtum
#----------------------------------------------------------

def body_top = Max(open, close);
def body_bottom = Min(open, close);
def upper_shadow = high - body_top;
def lower_shadow = body_bottom - low;
def candle_height = high - low;

def body_height_is_less_than_one_third_candle_height = candle_height > 3 * BodyHeight();
def upper_shadow_height_is_less_than_one_half_ish_candle_height = upper_shadow < (.001 + candle_height) / 2;
def lower_shadow_height_is_less_than_one_half_ish_candle_height = lower_shadow < (.001 + candle_height) / 2;

def smallbody = body_height_is_less_than_one_third_candle_height
and upper_shadow_height_is_less_than_one_half_ish_candle_height
and lower_shadow_height_is_less_than_one_half_ish_candle_height;

plot Spinning_Top = smallbody;

#-----------------------------------------------------------------------------------------
#Doji - Market is at a point of indecision. Highest high of doji and prior candle used for resistance. No support.
#-----------------------------------------------------------------------------------------

input length = 20;
input bodyFactor = 0.05;
Assert(bodyFactor >= 0, "'body factor' must not be negative: " + bodyFactor);
def Doji = IsDoji(length, bodyFactor);

plot DojiR = if Doji and high < high[1] then high[1] else if Doji and high >= high[1] then high else Double.NaN;
DojiR.SetPaintingStrategy(PaintingStrategy.DASHES);
DojiR.SetDefaultColor(Color.RED);
DojiR.SetLineWeight(2);

def DojiRext = if IsNaN(DojiR) then DojiRext[1] else DojiR;
plot DojiRextline = DojiRext;
DojiRextline.SetPaintingStrategy(PaintingStrategy.DASHES);
DojiRextline.SetDefaultColor(Color.RED);

#-------------------------------------------------------------------
#Inside Bar - Consolidation. There is a fight going on for direction
#-------------------------------------------------------------------

def IsUp = close > open;
def IsDown = close < open;
def IsDoji = IsDoji();
def avgRange = 0.05 * Average(high - low, 20);
def InsideBar =
((Sum(IsUp, 1)[1] >= 0)) and
((Sum(IsUp, 1)[0] >= 0)) and
Highest(high[1], 1) >= Highest(high[0], 1) and
Lowest(low[1], 1) <= Lowest(low[0], 1);

#-------------------------------------------------------------------------------------------
# High Wave Candlestick Pattern - Market is "confused." You do not want to stay in the trade
# Assembled by BenTen at useThinkScript.com
#-------------------------------------------------------------------------------------------

def Day = (high - low);
def Day_1 = (high[1] - low[1]);
def Day_2 = (high[2] - low[2]);
def Day_3 = (high[3] - low[3]);
def Day_4 = (high[4] - low[4]);
def Day_5 = (high[5] - low[5]);
def Avg = ((Day_1 + Day_2 + Day_3 + Day_4 + Day_5) / 5);
input Highwave_Wick_Multiplier = 3.0;
input Range_Multiplier = 1.0;

def Highwave = (((high - low) - (AbsValue(open - close))) > ((AbsValue(open - close)) * Highwave_Wick_Multiplier)) and ((Day > (Avg * Range_Multiplier)));

#----------------------------------------------------------------------
#Hammer - "A chance to buy at the bottom." Use Low of hammer as Support
#----------------------------------------------------------------------

def MovingAvg = 52;
def Avg2 = SimpleMovingAvg(close, MovingAvg);
def CandleBody = AbsValue(open - close);
def UpperWick = high - Max(open, close);
def LowerWick = Min(open, close) – low;
def Hammer = LowerWick > CandleBody * 2 and UpperWick <= LowerWick * 0.2 and low < low[1] and low < low[2] and low < low[3] and low < low[4] and low < low[5] and low < low[6] and low < low[7] and low < low[8] and close > Avg;

plot Hammer2 = if Hammer then low else Double.NaN;
Hammer2.SetPaintingStrategy(PaintingStrategy.DASHES);
Hammer2.SetDefaultColor(Color.GREEN);
Hammer2.SetLineWeight(2);
def hammer2ext = if IsNaN(Hammer2) then hammer2ext[1] else Hammer2;
plot Hammer2extline = hammer2ext;
Hammer2extline.SetPaintingStrategy(PaintingStrategy.DASHES);
Hammer2extline.SetDefaultColor(Color.GREEN);

#----------------------------------------------------------
#Bullish Engulfing - A Bottom Reversal. The bullish candle wraps around the entire body of the previous candle in a downtrend. Lowest low of the two sessions is Support.
#----------------------------------------------------------

def BullEngulf =
IsDescending(close, 3)[2] and
IsDown[1] and
IsUp[0] and
open[1] < close[0] and
close[1] >= open[0];

plot BullSupport = if BullEngulf and low > low [1] then low[1] else if BullEngulf and low <= low[1] then low else Double.NaN;
BullSupport.SetPaintingStrategy(PaintingStrategy.DASHES);
BullSupport.SetDefaultColor(Color.DARK_ORANGE);
BullSupport.SetLineWeight(2);
def Bullext = if IsNaN(BullSupport) then Bullext[1] else BullSupport;
plot Bullextline = Bullext;
Bullextline.SetPaintingStrategy(PaintingStrategy.DASHES);
Bullextline.SetDefaultColor(Color.DARK_ORANGE);

#----------------------------------------------------------------------------------------------
#Bullish Harami - Market in a downtrend. First Candle is unusually Long Downward Candle. Second candle has a small body within the prior red candle body. Prior trend is "losing breathe."
#----------------------------------------------------------------------------------------------

input length1 = 20;
input trendSetup1 = 3;
input bodyFactor1 = 0.3;
Assert(bodyFactor1 >= 0, "'body factor' must not be negative: " + bodyFactor1);

def BodyHeight = BodyHeight();
def IsShort = BodyHeight < bodyFactor1 * Average(BodyHeight, length);
def BodyMax = Max(open, close);
def BodyMin = Min(open, close);
def IsEngulfing = BodyMax < BodyMax[1] and
BodyMin > BodyMin[1];

plot BullishHarami = IsDescending(close, trendSetup1)[1] and
IsLongBlack(length)[1] and
IsEngulfing and
IsShort;

BullishHarami.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_UP);
BullishHarami.SetDefaultColor(color.green);

#----------------------------------------
#Bearish Candles - Typical Bearish Candles
#----------------------------------------

input length4 = 10;
def RedCandles =
IsLongBlack(length4);
plot Bearish = RedCandles;

#-------------------------
#Bearish Engulfing Candle - A Top Reversal. The bearish candle wraps around the entire body of the previous candle in a uptrend. Highest High of the two sessions is Resistance.
#-------------------------

def BearEngulf =
IsAscending(close, 3)[2] and
IsUp[1] and
IsDown[0] and
close[1] < open[0] and
open[1] > close[0];
plot BResistance = if BearEngulf and high < high[1] then high[1] else if BearEngulf and high >= high[1] then high else Double.NaN;
BResistance.SetPaintingStrategy(PaintingStrategy.DASHES);
BResistance.SetDefaultColor(Color.DARK_ORANGE);
BResistance.SetLineWeight(2);

def BRext = if IsNaN(BResistance) then BRext[1] else BResistance;
plot BRextline = BRext;
BRextline.SetPaintingStrategy(PaintingStrategy.DASHES);
BRextline.SetDefaultColor(Color.DARK_ORANGE);

#-----------------------------------------------------------------------------------------------
#Piercing Line - Market in Downtrend. Candle opens below prior low and closes more than 50% into prior down candle. Lowest low of the two candles is Support.
#-----------------------------------------------------------------------------------------------

input length2 = 20;
input trendSetup = 3;

def PierceCandle = IsDescending(close, trendSetup)[1] and
IsLongBlack(length2)[1] and
open < low[1] and
close > MidBodyVal()[1] and
close < open[1];
def PiercingLine = PierceCandle;

plot PierceSupport = if PiercingLine and low > low [1] then low[1] else if PiercingLine and low <= low[1] then low else Double.NaN;
PierceSupport.SetPaintingStrategy(PaintingStrategy.DASHES);
PierceSupport.SetDefaultColor(Color.CYAN);
PierceSupport.SetLineWeight(2);
def Pext = if IsNaN(PierceSupport) then Pext[1] else PierceSupport;
plot Pextline = Pext;
Pextline.SetPaintingStrategy(PaintingStrategy.DASHES);
Pextline.SetDefaultColor(Color.CYAN);

#------------------
#Dark Cloud Covers - Market in Uptrend. Candle opens above prior high and closes more than 50% into prior high candle. Highest high of the two candles is Resistance.
#------------------

def CloudCandle = IsAscending(close, trendSetup)[1] and
IsLongWhite(length)[1] and
open > high[1] and
close < MidBodyVal()[1] and
close > open[1];
def DarkCloudCover = CloudCandle;

plot DResistance = if DarkCloudCover and high < high[1] then high[1] else if DarkCloudCover and high >= high[1] then high else Double.NaN;
DResistance.SetPaintingStrategy(PaintingStrategy.DASHES);
DResistance.SetDefaultColor(Color.CYAN);
DResistance.SetLineWeight(2);
def DRext = if IsNaN(DResistance) then DRext[1] else DResistance;
plot DRextline = DRext;
DRextline.SetPaintingStrategy(PaintingStrategy.DASHES);
DRextline.SetDefaultColor(Color.CYAN);

#--------------
#Bearish Harami - Market in a uptrend. First Candle is unusually Long Upward Candle. Second candle has a small body within the prior green candle body. Prior trend is "losing breathe."
#--------------
Assert(bodyFactor >= 0, "'body factor' must not be negative: " + bodyFactor);

def BodyHeight1 = BodyHeight();
def IsShort1 = BodyHeight < bodyFactor * Average(BodyHeight, length);
def BodyMax1 = Max(open, close);
def BodyMin1 = Min(open, close);
def IsEngulfing1 = BodyMax < BodyMax[1] and
BodyMin > BodyMin[1];

plot BearishHarami = IsAscending(close, trendSetup)[1] and
IsLongWhite(length)[1] and
IsEngulfing and
IsShort;

BearishHarami.SetPaintingStrategy(PaintingStrategy.BOOLEAN_wEDGE_DOWN);
BearishHarami.SetDefaultColor(color.Red);

#----------------------------------------------------------------------------------------------
#Shooting Star - Market in an uptrend. Small real body of candle at or near the bottom of range
#Upper shadow at least 2x height of body of candle
#----------------------------------------------------------------------------------------------

input Star_length = 30;
input Star_trendSetup = 3;
input Star_bodyFactor = 0.3;
input Star_shadowFactor = 2.0;

Assert(Star_bodyFactor >= 0, "'body factor' must not be negative: " + Star_bodyFactor);
Assert(Star_shadowFactor >= 0, "'shadow factor' must not be negative: " + Star_shadowFactor);

def Star_BodyHeight = BodyHeight();
def Star_AverageBodyHeight = Average(Star_BodyHeight, Star_length);
def Star_ErrMargin = 0.25 * Star_AverageBodyHeight;
def Star_IsShort = Star_BodyHeight <= Star_bodyFactor * Star_AverageBodyHeight;

def ShootingStar = IsAscending(close, Star_trendSetup)[1] and

Star_IsShort and
Min(open, close) - low <= Star_ErrMargin and
high - Max(open, close) > Star_shadowFactor * Star_BodyHeight;
plot SSR = if ShootingStar then high else Double.NaN;
SSR.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SSR.SetDefaultColor(Color.Red);
def SSRext = if IsNaN(SSR) then SSRext[1] else SSR;
plot SSRextline = SSRext;
SSRextline.SetPaintingStrategy(PaintingStrategy.HORIZONTAL);
SSRextline.SetDefaultColor(Color.Red);

AssignPriceColor(if spinning_top then Color.BLUE else if Bullish then Color.GREEN else if Bearish then Color.RED else if BullEngulf or BearEngulf then Color.DARK_ORANGE else if Doji then Color.DARK_RED else if PiercingLine or DarkCloudCover then Color.CYAN else if Highwave then Color.PLUM else if InsideBar then Color.WHITE else if ShootingStar then Color.ORANGE else Color.CURRENT);
Hi thank you for sharing this. I can't see which part you turn off for "turn off the candle paint" in settings. Do you unclick show plot in the settings for the BearishHarami,Bullish Harami, DojiR, SpinningTop, and Hammer2? Or do you add hashtag in the actual code someplace? Thank you!
 
Last edited:
Hi thank you for sharing this. I can't see which part you turn off for "turn off the candle painting" in settings. Do you unclick show plot in the settings for the BearishHarami,Bullish Harami, DojiR, SpinningTop, and Hammer2? Or do you add hashtag in the actual code someplace? Thank you!

If you have a study that is painting the upper chart candles.
You can turn it off by putting a hashtag # in front of the AssignPriceColor statement in the code.
 
Last edited:
Is there a way too request? This was an awesome script. Thank you :)

I wanted too mimic it using the bearish patterns from TOS, but this is really complicated for me. lol
https://tlc.thinkorswim.com/center/reference/Patterns/candlestick-patterns-library/bearish-only
I could make watchlist columns for bear candles- I dont know how to code an indicator for bear candles.
My columns are set to 4h. You can right click on your watchlist and alter the timeline or add additional for daily candles.

You will need 2 columns as can only have 11 candles per watchlist.
Bear Candle Watchlist 1 http://tos.mx/SCgt4f6
Bear Candle Watchlist 2 http://tos.mx/An5szGj

@Musk335im3 @hockeycoachdoug @magnatron @EvilSurgeon
 
Last edited:

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
437 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