Outside Bars and/or Inside Bars (Candle) Combinations For ThinkOrSwim

Thepremier

New member
Can someone help me with a script for an outside day and and an inside day? I would like to create a scan for them.

 
Last edited:
@Thepremier Here you go:

Rich (BB code):
# Inside and Outside Bar
# Mobius
# 8.7.2017

def inside = high < high[1] and low > low[1];
def outside = high > high[1] or low < low[1];
AssignPriceColor(if inside
                then color.cyan
                else if outside
                    then color.yellow
                else color.current);

That indicator will plot outside and inside bars on your chart. Switch over to the Scan tab and use it as a scanner if you like. We also have Double Inside Day and Narrow Range Day as well.
 
Last edited:
I would like to contribute to this forum by offering to answer questions for those of you who are coding your own indicators. If you are stuck on something, perhaps I can help you figure it out.
Hi Robert. Can you tell me how to scan for Outside Bars on a daily/hourly? Thanks, coding is most difficult for me. Much appreciated.
 
@Lauri Here is the code for the outside bar

Code:
# Outside Bar
# Mobius
# 3.1.2016

# In order to mark outside bars with a YELLOW dot, just use
# change the arrows to points and the color to whatever you
# wish
#
# SetPaintingStrategy(PaintingStrategy.Points)

plot Bullish = high > high[1] and
               low < low[1] and
               close > open;
     Bullish.SetPaintingStrategy(PaintingStrategy.Boolean_Arrow_Up);
     Bullish.SetDefaultColor(Color.Green);
     Bullish.setLineWeight(3);

plot Bearish = high > high[1] and
               low < low[1] and
               close < open;
     Bearish.SetPaintingStrategy(PaintingStrategy.Boolean_Arrow_Down);
     Bearish.SetDefaultColor(Color.Red);
     Bearish.setLineWeight(3);

Watch this video if you need help with using the scanner.
 
@BenTen Thanks, it looks great on the chart! I am new to this, a great help. Is there a way (or video) to put this in the Scan Tab so I may get candidates to look at? That would be awesome!

Thanks so much,
Lauri
 
Hi @BenTen I was saying that the code is working great on the charts. And yes, I finally figured out how to run the scan. Great stuff! I don't know how you do that. I guess my question/goal is I would like to have a scan that can do multiple time frames on outside bars. Like a daily and hourly. How many columns can you have in a scan? Could 3 different time frames be scanned and displayed? Can we start with these questions?

Thx,
Lauri
 
@Lauri You can do that easily. Just select your timeframe of choice and hit Scan :)

tfH5r9G.png
 
Could you help me how to write a script for Inside bar? It doesn't matter on the color of the 1st bar and the 2nd bar...

Hi @BenTen , how do I put it on my scanner? I kind of forget how to put into a candle stick pattern first.

Thanks in advance
 
Can someone covert the following script to TOS?
thanks in advance

study(title="TW Golden Indicators", shorttitle="TW Golden Indicators", overlay=true)

src = input(close, title="Source")
length = input(20, minval=1)
mult = input(2.0, minval=0.001, maxval=50, title="StdDev")
basis = sma(src, length)
dev = mult * stdev(src, length)
upper = basis + dev
lower = basis - dev
plot(basis, "Basis", color=red, linewidth = 2, transp = 10)
p1 = plot(upper, "Upper", color=teal, linewidth = 2, transp = 10)
p2 = plot(lower, "Lower", color=teal, linewidth = 2, transp = 10)
fill(p1, p2, title = "Background of BB", color=#198787, transp=95)


inBar = low > low[1] and high < high[1]
outBar = low < low[1] and high > high[1]
holyGrail = low[1] < low[2] and high[1] > high[2] and low > low[1] and high < high[1]


//inside and outside using background highlight
barcolor (inBar == 1 ? white : na, title = "Inside Bar")
barcolor (outBar == 1 ? black : na, title = "Outside Bar")
plotshape(inBar == 1, style = shape.labelup, text = "IB", location = location.abovebar, color = white, textcolor = black)
plotshape(outBar == 1, style = shape.labeldown, text = "OB", location = location.belowbar, color = black, textcolor = white)
bgcolor (holyGrail == 1 ? yellow : na, offset = -1, title = "Holy Grail - Out Bar")
bgcolor (holyGrail == 1 ? yellow : na, title = "Holy Grail - In Bar")
 
@Laylabrador The top part of the code is just bollinger bands.
Code:
def inbar = low > low[1] and high < high[1];
def outbar = low < low[1] and high > high[1];
def holygrail = outbar[1] and inbar;

AddChartBubble(inbar and !holygrail, high, "IB", color.CYAN);
AddChartBubble(outbar and !holygrail[-1], high, "OB", color.MAGENTA);
AddChartBubble(holygrail, high, "Holy Grail - In Bar", color.CYAN);
AddChartBubble(holygrail[-1], low, "Holy Grail - Out Bar", color.CYAN, no);
 
I can't seem to get this working: Can someone take a look and see what's wrong here? Thanks I have no coding skills. This was posted on Twitter and said to work on TOS, but not for me.

// TW - Holy Grail
// highlights holy grail pattern

study(title="TW - Holy Grail", shorttitle="TW - Holy Grail", overlay=true)


outBar = low[1] < low[2] and high[1] > high[2]
inBar = low > low[1] and high < high[1]

holyGrail = inBar and outBar == 1

barcolor (holyGrail ==1 ? yellow : na)
barcolor (holyGrail ==1 ? yellow : na, offset = -1)
 
I can't seem to get this working: Can someone take a look and see what's wrong here? Thanks I have no coding skills. This was posted on Twitter and said to work on TOS, but not for me.

// TW - Holy Grail
// highlights holy grail pattern

study(title="TW - Holy Grail", shorttitle="TW - Holy Grail", overlay=true)


outBar = low[1] < low[2] and high[1] > high[2]
inBar = low > low[1] and high < high[1]

holyGrail = inBar and outBar == 1

barcolor (holyGrail ==1 ? yellow : na)
barcolor (holyGrail ==1 ? yellow : na, offset = -1)
What are the rules for Buy or Sell entry ?
 
Here is a simple version:

Code:
def outBar = low[1] < low[2] and high[1] > high[2];
def inBar  = low   >  low[1] and high    < high[1];

def holyGrail = inBar and outBar;

assignPriceColor(if holyGrail then color.yellow else color.current);
Thanks so much! I haven’t tried but I’m blown away how friendly everyone is to help out! Thank u...... 🙏🏼
 

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
160 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