Bull Flag and Bear Flag Formations for ThinkorSwim

BenTen

BenTen

Administrative
Staff
VIP
Warehouse
Ken Rose of TD Ameritrade recently shared a watchlist column that shows potential bull flag and bear flag patterns being formed. I modified it a little so that it can also plot bull flag signal and also bear flag signal on your chart.



Here is the watchlist column:

Code:
# [email protected] CBLOLD Search
#To use for scan place # signs before 2 Addlabel statements and change "def" before trigger statement to "plot"
##############Bull Flag
def StockPrice = close>=10;
def trend = simpleMovingAvg("length"=30)> (simpleMovingAvg("length"=30)[5]);
def MacdLow = macdHistogram(8,17,9)[1]< macdHistogram(8,17,9)[2]and close[1]<close[2] and close>high[1];
#def Momentum = macdHistogram(8,17,9) > macdHistogram(8,17,9)[1];
##############Bear Flag
def StockPriceBear = close>=10;
def trendBear = simpleMovingAvg("length"=30)< (simpleMovingAvg("length"=30)[5]);
def MacdHighBear = macdHistogram(8,17,9)[1]> macdHistogram(8,17,9)[2]and close[1]>close[2] and close<low[1];
#########################################
#def trigger = trend and momentum and MacdLow;
def Bulltrigger = trend and MacdLow;
def BearTrigger = TrendBear and MacdHighBear;

#AddLabel(yes, if Bulltrigger then "Bull Flag" else " ",Color.PLUM);
AddLabel(yes, if Bulltrigger then "Bull Flag" else if BearTrigger then "Bear Flag" else " ",Color.black);
AssignBackgroundColor(if Bulltrigger then color.YELLOW else if bearTrigger then color.LIGHT_RED else color.WHITE);
Shareable Link: http://tos.mx/nGYN7x



Here is the indicator

Code:
# Bull Flag and Bear Flag Indicator
# Original from https://twitter.com/KRose_TDA/status/1158974048518328320
# [email protected] CBLOLD Search
#To use for scan place # signs before 2 Addlabel statements and change "def" before trigger statement to "plot"
# Modified by BenTen at useThinkScript to Display Signals on Chart
##############Bull Flag
def StockPrice = close>=10;
def trend = simpleMovingAvg("length"=30)> (simpleMovingAvg("length"=30)[5]);
def MacdLow = macdHistogram(8,17,9)[1]< macdHistogram(8,17,9)[2]and close[1]<close[2] and close>high[1];
#def Momentum = macdHistogram(8,17,9) > macdHistogram(8,17,9)[1];
##############Bear Flag
def StockPriceBear = close>=10;
def trendBear = simpleMovingAvg("length"=30)< (simpleMovingAvg("length"=30)[5]);
def MacdHighBear = macdHistogram(8,17,9)[1]> macdHistogram(8,17,9)[2]and close[1]>close[2] and close<low[1];
#########################################
#def trigger = trend and momentum and MacdLow;
def Bulltrigger = trend and MacdLow;
def BearTrigger = TrendBear and MacdHighBear;

#AddLabel(yes, if Bulltrigger then "Bull Flag" else " ",Color.PLUM);
#AddLabel(yes, if Bulltrigger then "Bull Flag" else if BearTrigger then "Bear Flag" else " ",Color.black);
#AssignBackgroundColor(if Bulltrigger then color.YELLOW else if bearTrigger then color.LIGHT_RED else color.WHITE);

# Plot Confirmed Signals
plot bullish = Bulltrigger;
bullish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
bullish.SetDefaultColor(Color.CYAN);
bullish.SetLineWeight(1);
plot bearish = BearTrigger;
bearish.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
bearish.SetDefaultColor(Color.CYAN);
bearish.SetLineWeight(1);
Shareable link: http://tos.mx/5bxCeS
 
Last edited:
G

GetRichOrDieTrying

Member
Does this indicator repaint or are all of the signals shown the only signals printed?
 
D

drdarshil16

New member
VIP
best way to see is, if it works in mobile, it probably is not repainting. But that is just my observation. It may not be true. Although all the repainting indicators dont work on mobile
 
BenTen

BenTen

Administrative
Staff
VIP
Warehouse
@GetRichOrDieTrying I don’t think it repaint.
 

Top