Bollinger Reversal Scanner?


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?


Well-known member
2019 Donor
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;



New member
@Tradarr This probably belongs in its own thread as it would be nice to keep this thread related to the VOLATILITY BASED ENVELOPES... although i know it is based of creator Metastocks, they are all different studies and ideas. To answer your question.. your requested conversion would be difficult to convert without the base code used in the references that you posted in your scan. In other words your syntaxes are referencing other syntaxes and without those syntaxes its difficult to code.
I found the TOS shared item for the strategy, it is a strategy and not a shared scan so it would need to be converted. I found a strategy to study conversion example guide and will try. The current strategy script is below and the conversion example follows if someone else wants to try also:

#Detecting Swings Strategy Start
input swingType = {default "Pivot High-Low", "Bollinger Bands Crossover", "RSI Crossover", "RSI + Higher Low / Lower High"};
input length = 12;
input exitLength = 20;
input deviations = 2.0;
input overbought = 60;
input oversold = 40;
input averageType = AverageType.SIMPLE;

def rsi = reference RSI(length = length, "average type" = averageType);
def bbUpperBand = MovingAverage(averageType, close, length) + deviations * StDev(close, length);
def bbLowerBand = MovingAverage(averageType, close, length) - deviations * StDev(close, length);

def upSwing;
def downSwing;
switch (swingType) {
case "Pivot High-Low":
    upSwing = low[1] < low[2] and low[1] < low;
    downSwing = high[1] > high[2] and high[1] > high;
case "Bollinger Bands Crossover":
    upSwing = close crosses above bbLowerBand;
    downSwing = close crosses below bbUpperBand;
case "RSI Crossover":
    upSwing = rsi crosses above oversold;
    downSwing = rsi crosses below overbought;
case "RSI + Higher Low / Lower High":
    upSwing = rsi < oversold and low > low[1];
    downSwing = rsi > overbought and high < high[1];

def entryPrice = EntryPrice();
def afterEntryCount = if IsNaN(entryPrice[1]) and !IsNaN(entryPrice) then 1 else if !IsNaN(entryPrice) then afterEntryCount[1] + 1 else Double.NaN;

AddOrder(OrderType.BUY_TO_OPEN, upSwing, tickcolor = GetColor(0), arrowcolor = GetColor(0), name = "PriceSwingLE");
AddOrder(OrderType.SELL_TO_OPEN, downSwing, tickcolor = GetColor(1), arrowcolor = GetColor(1), name = "PriceSwingSE");
AddOrder(OrderType.BUY_TO_CLOSE, afterEntryCount > exitLength, tickcolor = GetColor(2), arrowcolor = GetColor(2), name = "PriceSwingLX");
AddOrder(OrderType.SELL_TO_CLOSE, afterEntryCount > exitLength, tickcolor = GetColor(3), arrowcolor = GetColor(3), name = "PriceSwingSX");
#Startegy End

Conversion Example

Convert Strategy To Study For Alerts Example

First, we'll show the full code that is copied directly from the built-in chart strategy named MACDStrat:

input fastLength = 12;
input slowLength = 26;
input macdLength = 9;
input averageType = AverageType.EXPONENTIAL;
def diff = reference MACD(fastLength, slowLength, macdLength, averageType).Diff;
AddOrder(OrderType.BUY_AUTO, diff crosses above 0, tickColor = GetColor(0), arrowColor = GetColor(0), name = "MACDStratLE");
AddOrder(OrderType.SELL_AUTO, diff crosses below 0, tickColor = GetColor(1), arrowColor = GetColor(1), name = "MACDStratSE");

Next, well convert this to a chart study by removing the AddOrder() statements. For the alerts, we simply add two Alert() statements to replace the AddOrder() statements. We will retain the true/false condition of the AddOrder() statements which are used to plot the theoretical buys and sells on the chart.

input fastLength = 12;
input slowLength = 26;
input macdLength = 9;
input averageType = AverageType.EXPONENTIAL;
def diff = reference MACD(fastLength, slowLength, macdLength, averageType).Diff;
Alert(diff crosses above 0, "MACD Hist Cross Above", Alert.BAR, Sound.RING);
Alert(diff crosses below 0, "MACD Hist Cross Below", Alert.BAR, Sound.RING);
AddLabel(yes, "", Color.BLACK);

Sorry but I can't figure out how to set up the plots for scan usage.

Similar threads