Bull Flag and Bear Flag Formations for ThinkorSwim

@Buckbull Possible to post the code here in this study? I avoid Watchlist links as it is not possible to DELETE any such watchlists once it has been imported
 
@BenTen I looked at Ken Rose's code, it seems that his definition of a bull flag has no mention of a typical flag pole vide the following snippet extracted from his code

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 Bulltrigger = trend and MacdLow;

I reviewed Mobius implementation of a bull flag scan - he uses a fractal energy computation as part of the equation amongst other things.
 
@tomsk Yup, this flag formation by Ken Rose is different from what you would look for in a typical flag pattern. Not sure why he called it that.
 
@Buckbull per your request here is Mobius Bull Flag scan

# Bull Flag on Pole - SCAN
# Mobius
# V01.02.2014

# Price trend - Upward leading to the pattern.
# Shape - A consolidation pattern forms.
# Volume - Recedes for best performance
# Confirmation - The pattern confirms as valid when price closes above the highest peak in the pattern.

input n = 21;

def upward = IsAscending(HL2, 65);
def p = (highest(high, 21) / close[65]) > 1.1;
def h = high;
def l = low;
def c = close;
def FE = (Log(Sum(TrueRange(h, c, l), n) /
(Highest(h, n) - Lowest(l, n))) /
Log(n)) > .68;
def LowVol = volume < Average(volume, 50);

plot Flag = upward and p and FE and LowVol;
 
I put it in a watch list https://tos.mx/Nn4Oje1 criteria $20.00 stock with a volume at or above 250,000. then I add the Bullflag Bearflag into my watchlist . I just go through the watchlist seeing where the MA's are and where the candle is in relation to the BB whether they are pointed up, down or flat . Thats what dictates if I get into trade or not

Hi @Buckbull , which BB length and standard deviation have you found to be most useful on the daily chart? - and do you play weeklies or month or so out for Options expiry?

Thanks!
 
@ganq he is a very talented and well versed in thinkscript, written thousands of wonderful studies, a professor, mathematician, programmer at large. Many of studies here like Opening Range Breakout, RSI Laguerre and others were written by him.
 
@ganq I change the length to 21 and leave the deviations alone 2 -2 . I buy monthlys 1 strike out of the money I buy 2 months out . You would be shocked how good 2 months out moves and you dont get really crushed on the pullbacks . I brought Dec 20 140 call on JAZZ today I made 64% today on it . What I brought for $2.15 a contract I sold for $3.50
 
@Buckbull per your request here is Mobius Bull Flag scan

# Bull Flag on Pole - SCAN
# Mobius
# V01.02.2014

# Price trend - Upward leading to the pattern.
# Shape - A consolidation pattern forms.
# Volume - Recedes for best performance
# Confirmation - The pattern confirms as valid when price closes above the highest peak in the pattern.

input n = 21;

def upward = IsAscending(HL2, 65);
def p = (highest(high, 21) / close[65]) > 1.1;
def h = high;
def l = low;
def c = close;
def FE = (Log(Sum(TrueRange(h, c, l), n) /
(Highest(h, n) - Lowest(l, n))) /
Log(n)) > .68;
def LowVol = volume < Average(volume, 50);

plot Flag = upward and p and FE and LowVol;
Does He have one for a Bear Flag as well ?
 
@Buckbull He sure does, here is the companion bear flag scan. Hope this helps

Code:
# Bear Flag on Pole - SCAN
# Mobius
# V01.02.2014
# Price trend - Downward leading to the pattern. The price should fall for at least 2 months.
# Shape - A consolidation pattern forms. It usually doesn't look like a flag or pennant, just a pause in the price decline.
# Volume - Recedes for best performance
# Confirmation - The pattern confirms as valid when price closes below the lowest trough in the pattern.

def o = open;
def h = high;
def l = low;
def c = close;
def BBl = BollingerBands().LowerBand;
def KCl = KeltnerChannels().Lower_Band;
def downward = isDescending(close, 42);
def p = (c[42] / lowest(l, 21)) > 1.2;
def squeezeLow = if BBl < KCl
                   then squeezeLow[1]
                   else if BBl crosses above KCl
                   then l
                   else if BBl > KCl and l < squeezeLow[1]
                        then l
                        else squeezeLow[1];
def NotSqueeze = BBl < KCl;
plot Flag = if downward and
               p and
               NotSqueeze and
               close crosses below squeezeLow
            then 1
            else Double.NaN;
# End Code Bear Flag
 

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

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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