Bollinger Bands Format, Watchlist, Label, Scan For ThinkOrSwim

adarty73

New member
Hi Im new with this, I was looking at some code I found that plots me the entry when the price touches the lower band of Bollinger Bands of the previous day and when the following day opens higher, also plots the exit signal when the RSI is lower than the previous day RSI and of opens lower.

declare lower;
plot signal=RSI()."RSI" crosses above 25 and low crosses below BollingerBands()."LowerBand" within 4 bars;
plot exit=RSI()."RSI" is less than RSI()."RSI" from 1 bars ago and high crosses above BollingerBands()."UpperBand" within 4 bars;

This is to identify possible reversal on Bollinger Bands, How can I implement into a Scanner that found stocks that are touching the bollinger Bands on the Dailychart with a possible of reversal?

someone can help me?
thanks
 
That is a simple scan if I understand what you are asking. Paste into thinkScript Editor under the Scan tab.

close crosses above BollingerBands()."LowerBand"

Link to image;

TENIloP.png
 

Attachments

  • TENIloP.png
    TENIloP.png
    157.3 KB · Views: 399
Anyone have a watchlist column that would alert when price crosses the upper or lower band?
Thanks
 
To scan the Universe of Stocks for equities whose price crosses Bollinger Bands and to receive alerts for these occurrences.
ascan.png

Scanner Setup For Bollinger Band Crossovers
This scans 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 the pencil next to the filter and changing the inputs as shown in the image below.


Shared Link to Scanner: http://tos.mx/LXMGqGa Click here for --> Easiest way to load shared links
fj7Qyn5.png


Set Up Alerts For Equities Found With The Scan
Screenshot (67).png

https://tlc.thinkorswim.com/center/howToTos/thinkManual/Scan/Stock-Hacker
 

Attachments

  • Screenshot (66).png
    Screenshot (66).png
    189.9 KB · Views: 618
Last edited:
@arod49 Per your request here is the COMPLETED code to color candles BLUE if they close above the Bollinger Upper band

Code:
input price = close;
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 = price[-displace], length = length);

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

AssignPriceColor(if close > UpperBand then Color.BLUE else Color.CURRENT);
 
You should be able to take this code and change it to what you are looking for. Any help needed let me know.


Code:
input price = close;
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 = price[-displace], length = length);

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

#UpperBand
def UBbu = close > UpperBand;
def UBbd = close < UpperBand and close > MidLine;

AddLabel(UBbu, " Price Above UpperBand @ " + close, Color.DARK_GREEN);
AddLabel(UBbd, " Price Below UpperBand @ " + close, Color.DARK_RED);

#LowerBand
def LBbu = close < LowerBand;
def LBbd = close > LowerBand and close < MidLine;

AddLabel(LBbu, " Price Below LowerBand @ " + close, Color.RED);
AddLabel(LBbd, " Price Above UpperBand @ " + close, Color.GREEN);
 
@tomsk is there any way we can have a chart label for each bollinger band...lower, mid, and upper band?? thanks...you are awesome!!!!!!!!!!!

@tradeking313 Didn't quite realize there is a bit of interest in the Bollinger Band. I took another look at it and made it visually more distinctive, and added alarms as well when it goes outside the band. Here then is version 1.1 if the study

Code:
# Bollinger Band with High Low Colored
# tomsk
# 12.14.2019

# V1.0 - 12.11.2019 - tomsk - Standard TOS BB tagged with BLUE candles when close above the upper band
# V1.1 - 12.14.2019 - tomsk - Adjustments to make display visually more distinctive and added alarms

input price = close;
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 = price[-displace], length = length);

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

MidLine.SetDefaultColor(Color.Yellow);
LowerBand.SetDefaultColor(Color.Cyan);
UpperBand.SetDefaultColor(Color.Green);

AssignPriceColor(if close > UpperBand then Color.Lime else if close < LowerBand then Color.Magenta else Color.Gray);

Alert(close crosses above UpperBand, "BB cross above Upper", Alert.BAR, Sound.Ring);
Alert(close crosses below LowerBand, "BB cross below Lower", Alert.BAR, Sound.Bell);
# End Bollinger Band
 
I'm looking for an edit to Bollinger band indicator. so statistically speaking, Bollinger bands show you how far the price is moving from its moving averages and that's based on standard deviations which shows the statistical significance of that price level. so based on that you know how likely it is for the price action is to stay there and as if its gonna start moving closer to its average and eventually reverse. so with that I have been using 2 Bollinger bands with std of 1 and another with std of 2.5. I short the future or stock when its below its 10 and 20 moving averages and also crossing below 1std from BBand with 10 moving average and start covering my position and trimming when it reaches the 2.5 standard deviation and taking profits. that being said, to make it easer to recognize the entry I was looking for a version of BBands that highlights the area between the 2 upper bands and 2 lower bands of 2 BBands with one being standard deviation of 1 and another 2.5. please let me know if that's possible. thank you!

entry example on 1h chart of /ES:

Untitled.png
 
Last edited by a moderator:
Is this what you're looking for?

Code:
# Bollinger Bands with Cloud
# TD Ameritrade IP Company, Inc. (c) 2007-2020
#

input price = close;
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 = price[-displace], length = length);

plot MidLine = MovingAverage(averageType, data = price[-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));

AddCloud(Midline, UpperBand, color.green, color.green);
AddCloud(Midline, LowerBand, color.red, color.red);
 
so if you can add another bollinger band with sd of 1 and only highlight the area between the 2 upperS and 2 lowerS then would be perfect! @BenTen
area around moving average should be empty and not highlighted
 
Last edited:
@Aliikhatami Here you go:

Code:
#
# Double Bollinger Bands
# Assembled by BenTen at useThinkScript.com
# Based on request/concept of @aliikhatami

input price = close;
input displace = 0;
input length = 20;
input Num_Dev_Dn1 = -1.0;
input Num_Dev_up1 = 1.0;
input Num_Dev_Dn3 = -3.0;
input Num_Dev_up3 = 3.0;
input averageType = AverageType.EXPONENTIAL;

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

plot MidLine = MovingAverage(averageType, data = price[-displace], length = length);
plot LowerBand1 = MidLine + num_Dev_Dn1 * sDev;
plot UpperBand1 = MidLine + num_Dev_Up1 * sDev;
plot UpperBand3 = MidLine + num_Dev_Up3 * sDev;
plot LowerBand3 = MidLine + num_Dev_Dn3 * sDev;

AddCloud(UpperBand1, UpperBand3, color.green, color.green);
AddCloud(LowerBand1, LowerBand3, color.red, color.red);
 
Need help for scanning stocks for "Stocks which Touched their Lower Bollinger Band" - Can someone help with the steps or tos script.
 
Last edited:
The TOS Conditional Wizard gave this as automated code generation...
Code:
low crosses below BollingerBandsCrossover("band" = "lower", "crossing type" = "below")
 

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