Bollinger Bands Format, Watchlist, Label, Scan For ThinkOrSwim

Hello Everyone,

I would like to have a scanner that Scans for stocks that fall in the “buy zone,” between one and two standard deviations above the moving average.

can someone help please.

Thank you in advanced.
 

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

@Marcoxiii I think this is what you're looking for

Ruby:
close is greater than BollingerBands("num dev up" = 1.0)."UpperBand" and close is less than BollingerBands()."UpperBand"
 
Is there a way to scan, if a bollinger band is trending upward, (eg midline, midline[2], midline[4] and midline[6] are all trending up) appreciate it.
 
Is there a way to scan, if a bollinger band is trending upward, (eg midline, midline[2], midline[4] and midline[6] are all trending up) appreciate it.

The Bollinger Band midline is merely a SMA20 so that's all you'd need to find the same trend as the Bollinger Band midline... No need further complicating things by attempting to use Bollinger Bands... 💡
 
Chart will turn grey and display upper/lower bb limits by positive/negative numerical values

Code:
#Out of Bounds
def sDev = StDev(close, 21);
def MidLine = Average(close, 21);
def UpperBand = MidLine + 2 * sDev;
def LowerBand = MidLine - 2 * sDev;
plot OOB = if close > UpperBand then Round(close - UpperBand, 2) else if close < LowerBand then Round(close - LowerBand, 2) else Double.NaN;
AssignBackgroundColor(if !isnan(oob) then color.white else color.gray);
OOB.assignvalueColor(if !isnan(oob) then color.black else color.gray);

Sound alerts script.

https://tos.mx/Pd1xADc
 
Last edited by a moderator:
Is it possible to make a Bollinger band indicator when the stocks end out of the bands at the end of the trading day going up or down?
 
close from 1 bars ago is greater than or equal to BollingerBands()."UpperBand" from 1 bars ago or close from 1 bars ago is less than or equal to BollingerBands()."LowerBand"[1]
 
Code:
input aggregationPeriod=AggregationPeriod.day;
def data = close(period = aggregationPeriod);
input displace = 0;
input length = 20;
input Num_Dev_Dn = -2.0;
input Num_Dev_up = 2.0;
input averageType = AverageType.Simple;

def sDev = stdev(data = data[-displace], length = length);

plot MidLine = MovingAverage(averageType, data = data[-displace], length = length);
plot LowerBand = MidLine + num_Dev_Dn * sDev;
plot UpperBand = MidLine + num_Dev_Up * sDev;

LowerBand.SetDefaultColor(GetColor(0));
MidLine.SetDefaultColor(GetColor(1));
UpperBand.SetDefaultColor(GetColor(5));
 
I'd love to use a bollinger bands indicator with the green/red coloring style of the Hull Moving Average, meaning the bands would be colored green when in an uptrend and would turn red when in a downtrend. Is that possible to code?
 
Ruby:
plot Upper = reference BollingerBands.UpperBand;
Upper.AssignValueColor(if Upper > Upper[1] then Color.UPTICK else Color.RED);

plot Middle = reference BollingerBands.MidLine;
Middle.AssignValueColor(if Middle > Middle[1] then Color.UPTICK else Color.RED);

plot Lower = reference BollingerBands.LowerBand;
Lower.AssignValueColor(if Lower > Lower[1] then Color.UPTICK else Color.RED);
 
Last edited:
I just noticed I didn't update each line to color based on its own being higher or lower. Each was looking at the Upper band. Fixing in original post.
It did look a little funny, but I wasn't complaining. I'll use the update! Thanks so much.
 
Need help with adding alert on the MovingAverage envelope indicator. Examples alerts me when price touches the upper band. Also want it to be set at a continuous basis.like everytime price touchses the upper or lower band i get n alert.
Thanks in advance
 
@yman So when you say "the MovingAverage envelope indicator", do you mean Bollinger Bands?
ascan.png


If you are looking to scan the Universe of Stocks for equities whose price crosses Bollinger Bands and to receive alerts for these occurrences, here are your instructions --> https://usethinkscript.com/threads/all-things-bollinger-bands.762/#post-74355

If you are looking to receive an alert on a specific stock on a specific chart that you are looking at,
then use this chart alert link: http://tos.mx/EBfuNiW Click here for --> Easiest way to load shared links

Alert Setup For Bollinger Band Crossovers
This alerts for:
stock prices crossing above the standard deviation of 2.0 of a simple moving average of 20
AND
stock prices crossing below the standard deviation of 2.0 of a simple moving average of 20
The above highlighted elements can be edited by clicking on edit and changing the inputs as shown in the image below.
l2Kj4a5.png
 
Hi guys how are you? Can you help me with the original code of TOS to set sound alerts?

Thanks guys!!!

This is the code.

#
# TD Ameritrade IP Company, Inc. (c) 2009-2021
#

#wizard text: CLOSE
#wizard input: crossingType
#wizard input: band
#wizard text: Inputs: length:
#wizard input: length
#wizard text: std deviation:
#wizard input: Std_Deviation
#wizard text: average type:
#wizard input: averageType

input length = 20;
input Std_Deviation = 2.0;
input band = {default upper, middle, lower};
input crossingType = {default above, below};
input averageType = AverageType.SIMPLE;

def bollinger;
switch (band) {
case upper:
bollinger = BollingerBands(length = length, Num_Dev_Dn = -Std_Deviation, Num_Dev_up = Std_Deviation, averageType = averageType).UpperBand;
case middle:
bollinger = BollingerBands(length = length, Num_Dev_Dn = -Std_Deviation, Num_Dev_up = Std_Deviation, averageType = averageType).MidLine;
case lower:
bollinger = BollingerBands(length = length, Num_Dev_Dn = -Std_Deviation, Num_Dev_up = Std_Deviation, averageType = averageType).LowerBand;
}

plot signal = Crosses(close, bollinger, crossingType == CrossingType.above);

signal.DefineColor("Above", GetColor(1));
signal.DefineColor("Below", GetColor(2));
signal.AssignValueColor(if crossingType == CrossingType.above then signal.color("Above") else signal.color("Below"));

signal.SetPaintingStrategy(if crossingType == CrossingType.above
then PaintingStrategy.BOOLEAN_ARROW_UP
else PaintingStrategy.BOOLEAN_ARROW_DOWN);
 
Ruby:
plot Upper = reference BollingerBands.UpperBand;
Upper.AssignValueColor(if Upper > Upper[1] then Color.UPTICK else Color.RED);

plot Middle = reference BollingerBands.MidLine;
Middle.AssignValueColor(if Middle > Middle[1] then Color.UPTICK else Color.RED);

plot Lower = reference BollingerBands.LowerBand;
Lower.AssignValueColor(if Lower > Lower[1] then Color.UPTICK else Color.RED);
can be possible to have a dot signal every time the price hit the over sold and over buy zone?
 

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