Bull Flag and Bear Flag Formations for ThinkorSwim

J

joshua74133

Member
VIP
my flag settings are 3,15,5,5 for the 1min chart. how could I get these 2 to work together?
 
B

Buckbull

Member
Tom one more for you, What do I need to delete from this to put it in a scan so I will be alerted when a 1 hour or a 15 min chart fires off a signal for a Bullflag or Bearflag
 
Last edited by a moderator:
T

tomsk

Well-known member
VIP
@Buckbull That scan code you have looks fine. All you need to do is to delete the AddLabel and AssignBackgroundColor statements as it has no relevance to the scan result.
 
T

tomsk

Well-known member
VIP
@Buckbull You sure are a fan of Ken Rose it seems! Here is your scan code, it is configured for a bull scan. To change this to a bear scan, just comment out the bull scan line at the end of the code and uncomment the bear scan. The scanner can ONLY have one active plot at any time

Code:
# Follow @KRose_TDA on twitter for updates to this and other scripts
# Thanks to Alan Burch for emoji enhancement
# For Bull Flag Scan change "def" before Bulltrigger statement to "plot"
# For Bear Flag scan change "def" before BearTrigger Statement to "Plot"

def FlagDistance = .75; #Percent of ATR from high/low

# Bull Flag
def StockPrice = close>=10;
def FATR = ATR();
def trigATR = (highest(high,5)-close)> (FlagDistance*FATR); #flag slopping down
def PriceSma = close>simpleMovingAvg("length"=30); #Trend still in force
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];
#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];
def BFATR = reference ATR();
def BtrigATR = (close-lowest(low,5))> (FlagDistance*FATR); #flag slopping up
def BPriceSma = close<simpleMovingAvg("length"=30); #Trend still in force

# Delete (#) the plot not needed

plot Bulltrigger = trend and MacdLow and trigATR and PriceSma;
# plot BearTrigger = TrendBear and MacdHighBear and BtrigATR and BPriceSma ;
 
B

Buckbull

Member
lol yes I am a fan of his work . Im a fan of your work as well because of you I able to use the scan. Cant thank you enough.
 
B

Buckbull

Member
@Buckbull You lost me , I understand to do a Bear Flag I take out the Bull flag script stuff but not really sure how much of the script I take out? Sorry
 
BenTen

BenTen

Administrative
Staff
VIP
@Buckbull There is no need to remove anything. Take a look at the last portion of the script @tomsk provided. Follow the instruction in there as well.

Code:
# Delete (#) the plot not needed

plot Bulltrigger = trend and MacdLow and trigATR and PriceSma;
# plot BearTrigger = TrendBear and MacdHighBear and BtrigATR and BPriceSma ;
The snippet above will scan for bull flag signals. Now, if you want to scan for bear flags, then add "#" in front of plot Bulltrigger and remove the # sign from the plot BearTrigger.
 
H

HighBredCloud

Well-known member
VIP
What time frame does this column seem to work the best at? I have tried this on 5 15 30 min and the signals given did not happen as what they displayed...Is this ONLY good for a DAILY chart?
 
M

maddy91

New member
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: https://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: https://tos.mx/5bxCeS

New Watchlist Update



Ken Rose recently updated his watchlist column. Here is the new code with a bit more customization :)

Code:
# Follow @KRose_TDA on twitter for updates to this and other scripts
# Thanks to Alan Burch for emoji enhancement
# Thumbs up = potential Bull Flag - Thumbs Down potential bear flag
# To use for scan place # signs before 2 Addlabel statements.
# For Bull Flag Scan change "def" before Bulltrigger statement to "plot"
# For Bear Flag scan change "def" before BearTrigger Statement to "Plot"
#Enter desired distance of flag by changing FlagDistance value
def FlagDistance = .75; #Percent of ATR from high/low
##############Bull Flag
def StockPrice = close>=10;

##############ThinkScriptWebcast##################
def FATR = ATR();
def trigATR = (highest(high,5)-close)> (FlagDistance*FATR); #flag slopping down
def PriceSma = close>simpleMovingAvg("length"=30); #Trend still in force

##########################################
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];
#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];
#########################################
##############ThinkScriptWebcast##################
def BFATR = reference ATR();
def BtrigATR = (close-lowest(low,5))> (FlagDistance*FATR); #flag slopping up
def BPriceSma = close<simpleMovingAvg("length"=30); #Trend still in force

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

def Bulltrigger = trend and MacdLow and trigATR and PriceSma;
def BearTrigger = TrendBear and MacdHighBear and BtrigATR and BPriceSma  ;

AssignBackgroundColor(if Bulltrigger then color.YELLOW else if bearTrigger then color.LIGHT_RED else color.WHITE);

##########################################################
AddLabel(yes, if Bulltrigger then "👍" else if BearTrigger then "👎" else " ", if BearTrigger  then Color.dark_red else if Bulltrigger then Color.dark_GREEN else Color.ORANGE);
AssignBackgroundColor(color.light_ORANGE);
############################################################
Shareable Link: https://tos.mx/6xou4xs

I added this Study but it does not seem to function properly.
Could not attach the image but here is the link. Image

Thanks @BenTen ,
FYI, I just found this amazing page today and I AM IMPRESSED. Excellent Work
 
D

daredevilxv5

New member
@BenTen dumb question ? I know how to paste the indicator but how do I plug in the code for watchlist bullflag ken rose
 
BenTen

BenTen

Administrative
Staff
VIP
@daredevilxv5 It's under Watchlist > Customize > Custom Quotes. Select one of the option in there and paste the code in. Also, be sure to adjust the timeframe.
 
S

Shahrom

New member
I just added both code to my watchlist and they don’t match. I am not coder but are the parameters different for each code?



@BenTen
 
Last edited by a moderator:
BenTen

BenTen

Administrative
Staff
VIP
@Shahrom Probably because the second version has been updated/modified.
 
B

bp805

New member
@tomsk - I'm new to ToS and indicators/scans and trying to set some things up in my account.

If I'm not mistaken, you have to have the custom indicator loaded into ToS before scanning for it, correct? Is there an accompanying indicator to go along with this Mobius bull flag scan, or am I missing something? I loaded the script into the studies in ToS but dont get any results on any charts. I tried to use the "intradayflagformation" study that comes with ToS, but curious what this one from Mobius might produce for bull flags and want to have some indicators plotted on my charts.

Also, where are you pulling all of these custom Mobius indicator scripts from? Mytrade.com or somewhere else?

Thanks!
 
J

JonPM

New member
@Buckbull Curious if you are still using this script/scan/watchlist? how has it been working for you?
 

Similar threads

Top