ThinkorSwim Bollinger Bands Scanner

sanben

New member
Need help for scanning stocks for "Stocks which Touched their Lower Bollinger Band" - Can someone help with the steps or tos script.
 
Last edited:

rad14733

Well-known member
VIP
The TOS Conditional Wizard gave this as automated code generation...
Code:
low crosses below BollingerBandsCrossover("band" = "lower", "crossing type" = "below")
 

rad14733

Well-known member
VIP
@rad14733 No luck, I cant find any stocks which are touching lower band and or outsider lower band
During regular trading hours...??? I only tested it on GDX because I already had the chart up so I just added the script as a lower study... It fired off more than a few times before I finally removed the study... It was just your code with the two alert lines added... I never bothered to check the semantics of your code, just added the alerts based on your plot conditions...
 

sritrade

New member
VIP
Hello everyone, First of all, thank you for your response and here is the help that I need:

Can some one help me with an indicator which tells me when "5 minute lower Bollinger Band" is touching "Daily lower Bollinger Band".
 

germanburrito

Active member
put it on a 5 minute time frame and it should work

Code:
# DG_MTFBollingerBands
# Paints Bollinger Bands from higher time period
# onto current time period
#German BUrrito
# Copyright (c) 2017 Daniel Granville
declare lower;
input timeframe = AggregationPeriod.DAY;
input period = 20;
input std = 2.0;
input moving_average_type = {default SMA, EMA};

def data = close(period = timeframe);
def band = StDev(data, period);

plot MidLine;

switch(moving_average_type) {
    case SMA:
        MidLine = Average(data, period);
    case EMA:
        MidLine = ExpAverage(data, period);
}

plot BBandTop = MidLine + band;

plot BBandBot = MidLine - band;


#
# TD Ameritrade IP Company, Inc. (c) 2007-2020
#

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

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

LowerBand.SetDefaultColor(GetColor(0));
MidLine.SetDefaultColor(GetColor(1));
UpperBand.SetDefaultColor(GetColor(5));



def U = LowerBand <=  BBandBot ;
def D = lowerband >=  BBandBot;



AddLabel( U, " down " , Color.red);
AddLabel( D, " up " , Color.green);
 

sritrade

New member
VIP
Thank you so much Germanburrito and it is really helpful.
However, my expectation was to have it as a scan and I am getting error while trying to paste this code (by removing addlabel kind of statements in scan. Could you be able to help me here please?
All I need is - at this moment, I would like to know the tickers where the price is below 5 mins Lower Bollinger band and daily Bollinger Band levels.
I am getting error as "Secondary period not allowed" while giving this in scan.
Many thanks in advance!

 

sritrade

New member
VIP
Thanks for the quick response but it seems I am still getting the same error. Scan is working good when Day is selected (but obviously resulting no rows - which is expected), but when changing it to 5 minutes, I am getting the error as "Secondary period not allowed: Day" because of Day is being considered within the script.

Can you please help me?
 

Marcoxiii

New member
VIP
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.
 

rad14733

Well-known member
VIP
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... 💡
 

tarheelnga

New member
Is there a code, or how do I set up a scanner on ToS that will allow me to pick up first candle back inside of the lower band. Also, is there a way to find when the bands first expand/widen after a squeeze
 

hsan1985

New member
VIP
Guys, would like to seek for advise for below condition Scanner, is it able to scan some BB width? as below condition?
set bb to 40
bb width need to be below 10.... for past "150 (this can be variable)" candle
trigger: price close above bb (normal bb 20)/ macd cross

164825267_10158837972902110_1704956598857227756_o.jpg
 

Similar threads

Top