Skip to main content Bollinger Bands Reversal Indicator TOS Skip to main content Skip to content
Master the TTM Squeeze with our comprehensive 19-module course Start Learning →
TOS Indicators
  • Tools

    Categories

    • Indicators
    • Backtesters
    • Scans
    • Dashboards
    • thinkScript
    • Member Resources
    Browse Full Library

    Featured Tutorials

    Heiken Ashi Trend Indicator
    Heiken Ashi Trend Indicator
    Indicators

    Download our Custom Heiken Ashi indicator for ThinkOrSwim. Full ThinkScript code, formula...

    Learn more →
    Commodities Tracker
    Commodities Tracker
    Indicators

    For acceleration signals: trend-following strategies and buying pullbacks. For deceleration signals: short...

    Learn more →
    Build an Election Backtester in 10 Minutes
    Build an Election Backtester in 10 Minutes
    Backtesters

    Learn how to create a Post-Election Backtester in ThinkOrSwim to analyze market...

    Learn more →

    Popular Posts

    Unusual Volume
    Unusual Volume
    Scans

    Build 4 scans to easily find stocks with greater than...

    Learn more →
    Upcoming Earnings with High Short Interest
    Upcoming Earnings with High Short Interest
    Scans

    Build a scan to find stocks that are likely to...

    Learn more →
    Unusual Volume Pro Scans
    Unusual Volume Pro Scans
    Scans

    4 additional scans to find unusual volume overlapping with key...

    Learn more →
  • Courses
    Squeeze Course
    Squeeze Course
    19 Modules

    Scan, backtest, and trade the TTM Squeeze setup with precision.

    Unlock Course →
    Earnings Course
    Earnings Course
    3 Modules

    Master earnings plays with free indicators and proven strategies for ThinkOrSwim.

    Unlock Course →
    V-Shaped Reversals
    V-Shaped Reversals
    7 Modules

    Identify and trade powerful V-shaped reversal patterns with confidence and precision.

    Unlock Course →
    Fibonacci Trading
    Fibonacci Trading
    4 Modules

    Learn to trade Fibonacci retracements and extensions in ThinkOrSwim effectively.

    Unlock Course →
  • Products
    Futures Volatility Box Premium
    Futures Volatility Box

    Volatility models for 10 major futures markets, including micros & SPX.

    Explore Futures VB →
    Stock Volatility Box Premium
    Stock Volatility Box

    Dynamic support & resistance for 595+ stocks/ETFs, with a live scanner.

    Explore Stock VB →
    Opening Range Breakouts Premium
    Opening Range Breakouts

    Powerful live scanner & backtester for ORB strategies on 595+ stocks.

    Explore ORB Setups →
My Account
Back to Tutorials
Beginner-Friendly 15 mins ThinkOrSwim

Bollinger Bands Reversal

Master the most popular Bollinger Bands trading strategy with our complete reversal indicator for ThinkOrSwim. Learn to identify high-probability mean reversion trades with precise entry signals.

Download Indicator
How to install in ThinkOrSwim →
Table of Contents
  • The Complete Guide to Building a Bollinger Bands Reversal Indicator in ThinkOrSwim
  • Understanding Bollinger Bands and Mean Reversion Theory
  • The Strategy Framework: Two Critical Requirements
  • Building the Indicator: Complete Step-by-Step Coding Tutorial
  • Getting Started in ThinkOrSwim
  • Step 1: Defining the Bollinger Band Components
  • Step 2: Building the Core Requirements
  • Step 3: Adding Smart Signal Filtering
  • Step 4: Creating the Trading Signals
  • Step 5: Formatting the Visual Signals
  • Step 6: Testing Your Indicator
  • Understanding the Signal Logic in Action
  • Advanced Signal Filtering: Eliminating False Positives
  • Signal Visualization and Chart Integration
  • Multi-Timeframe Application Strategies
  • Risk Management and Trade Execution
  • Market Context and Environmental Factors
  • Advanced Customization and Optimization
  • Integration with Other Technical Indicators
  • Common Mistakes and How to Avoid Them
  • Performance Tracking and Continuous Improvement
  • Conclusion: Putting Theory into Practice

Master Bollinger Bands Mean Reversion Trading

In this step-by-step ThinkOrSwim coding tutorial, we’ll build a reversal indicator, using the Bollinger Bands.

The Bollinger Bands Reversal indicator that we’ll build is useful for capitalizing on mean reversion trades, and taking advantage of price movements outside the standard Bollinger Bands. The indicator identifies potential reversal points, plotting buy and sell signals based on specific conditions.

You’ll learn how to build and use the most popular Bollinger Bands trading strategy that automatically identifies high-probability reversal opportunities in ThinkOrSwim.

This proven mean reversion strategy helps you:

  • Spot oversold and overbought conditions with precision
  • Identify reversal signals before major price movements
  • Filter out false breakouts using smart confirmation logic
  • Trade with clear entry and exit rules

Perfect for both day traders and swing traders looking to capitalize on price extremes and mean reversion patterns across any timeframe.

Let’s dive into the steps required to code this indicator in ThinkOrSwim’s thinkScript.

The Complete Guide to Building a Bollinger Bands Reversal Indicator in ThinkOrSwim

The Bollinger Bands reversal strategy remains one of the most widely-used mean reversion approaches in trading. When price moves outside the statistical boundaries of normal price action, it often signals an opportunity for price to snap back toward the mean. This comprehensive guide will show you how to build a sophisticated Bollinger Bands reversal indicator that eliminates false signals and identifies high-probability trading opportunities.

Understanding Bollinger Bands and Mean Reversion Theory

Bollinger Bands consist of three components: a simple moving average (typically 20 periods) serving as the middle line, and upper and lower bands set at two standard deviations from this average. When price moves beyond these bands, it indicates that the asset is trading at statistical extremes relative to its recent price behavior.

The mean reversion principle suggests that prices tend to return to their average over time. When a stock breaks outside the Bollinger Bands, it’s trading at levels that are statistically unusual, creating potential for a reversal back toward the middle band. However, not every band touch results in an immediate reversal, which is why our indicator includes specific confirmation criteria.

The Strategy Framework: Two Critical Requirements

Our Bollinger Bands reversal indicator operates on two fundamental requirements that must both be satisfied for a valid signal. This dual-confirmation approach significantly reduces false signals compared to simple band touch strategies.

Requirement 1: Price Extension Beyond Bands

For bullish signals, the previous candle’s low must break below the lower Bollinger Band. For bearish signals, the previous candle’s high must exceed the upper Bollinger Band. This requirement ensures we’re only considering trades when price has moved to statistical extremes.

Requirement 2: Reversal Confirmation

The current candle must show signs of reversal momentum. For long setups, the current candle’s close must be higher than the previous candle’s high. For short setups, the current candle’s close must be lower than the previous candle’s low. This confirmation helps ensure we’re entering trades with momentum in our favor rather than catching a falling knife.

Building the Indicator: Complete Step-by-Step Coding Tutorial

Now let’s walk through building this indicator from scratch in ThinkOrSwim. This hands-on tutorial will show you exactly how to create your own Bollinger Bands reversal indicator using ThinkScript code.

Getting Started in ThinkOrSwim

To begin building our custom indicator, open ThinkOrSwim and navigate to your charts. Click the Studies icon in the top toolbar, then select “Create” to start building your own indicator. Give your indicator a descriptive name like “Bollinger Bands Reversal” so you can easily find it later.

Once you’re in the ThinkScript editor, delete any default code that appears and we’ll start building from scratch. The beauty of this indicator lies in its elegant simplicity – despite requiring only a few lines of code, it implements sophisticated logic that professional traders use daily.

Step 1: Defining the Bollinger Band Components

The first step is defining variables for each component of the Bollinger Bands. This approach makes our code more readable and allows us to easily reference specific bands throughout our logic. We’ll need three components: the upper band, lower band, and midline.

Start by typing the following code to define your Bollinger Band components:

def lowerBand = BollingerBands().lowerBand;

def upperBand = BollingerBands().upperBand;

def mid = BollingerBands().MidLine;

These definitions create clean variable names that reference the default Bollinger Bands study built into ThinkOrSwim. The default settings use a 20-period simple moving average with 2 standard deviations, which work well for most trading applications.

Step 2: Building the Core Requirements

Remember our two key requirements: price must break outside the bands, and we need momentum confirmation. Let’s translate these requirements into ThinkScript conditions.

Requirement 1: Price Outside the Bands

For our first set of conditions, we need to check if the previous candle’s price action extended beyond the Bollinger Bands:

def cond1 = low[1] < lowerBand[1];

def cond2 = high[1] > upperBand[1];

Condition 1 checks if yesterday's low was below the lower Bollinger Band - this sets up our potential long trade. Condition 2 checks if yesterday's high exceeded the upper Bollinger Band - this sets up our potential short trade. The [1] notation refers to the previous bar's data.

Requirement 2: Momentum Confirmation

Next, we need to verify that the current candle shows signs of reversal momentum:

def cond3 = close > high[1];

def cond4 = close < low[1];

Condition 3 confirms bullish momentum by checking if today's close is above yesterday's high. Condition 4 confirms bearish momentum by checking if today's close is below yesterday's low. This momentum confirmation is crucial for avoiding false signals.

Step 3: Adding Smart Signal Filtering

At this point, we have a basic working system, but we can make it much smarter by adding filtering logic. Without this filtering, the indicator might give signals after the mean reversion opportunity has already passed.

Add two more conditions to check if the reversion opportunity still exists:

def cond5 = high < mid;

def cond6 = low > mid;

Condition 5 ensures that for long trades, the current candle's high hasn't yet reached the midline - meaning there's still upside potential. Condition 6 ensures that for short trades, the current candle's low hasn't yet reached the midline - meaning there's still downside potential.

This filtering dramatically improves signal quality by eliminating late entries where the mean reversion has already occurred.

Step 4: Creating the Trading Signals

Now we combine our conditions to create the actual buy and sell signals. Instead of using "def" (which creates internal variables), we use "plot" because we want these signals to appear on our chart:

plot bullSignal = cond1 and cond3 and cond5;

plot bearSignal = cond2 and cond4 and cond6;

The bullSignal requires all three bullish conditions: previous low below lower band, current close above previous high, and current high below midline. The bearSignal requires all three bearish conditions: previous high above upper band, current close below previous low, and current low above midline.

Step 5: Formatting the Visual Signals

To make these signals visible as arrows on your chart, add the following formatting code:

bullSignal.SetPaintingStrategy(PaintingStrategy.Boolean_Arrow_Up);

bullSignal.setLineWeight(3);

bearSignal.SetPaintingStrategy(PaintingStrategy.Boolean_Arrow_Down);

bearSignal.setLineWeight(3);

This code displays buy signals as green arrows pointing up and sell signals as red arrows pointing down. The line weight of 3 makes the arrows clearly visible without cluttering your chart.

Step 6: Testing Your Indicator

Click "Apply" to load your newly created indicator onto your chart. You should now see buy and sell arrows appearing when your conditions are met. Load the standard Bollinger Bands study alongside your indicator to verify that signals are appearing at the correct moments.

Test the indicator on different timeframes to see how it performs. The same code works on any timeframe - from 1-minute charts for day trading to daily charts for swing trading. Each timeframe will use the appropriate Bollinger Bands calculation for that period.

Understanding the Signal Logic in Action

When you see a buy arrow appear, it means three things happened simultaneously: the previous candle's low broke below the lower Bollinger Band (showing an extreme move), the current candle closed above the previous candle's high (showing reversal momentum), and the current candle's high is still below the midline (showing remaining upside potential).

Similarly, sell arrows appear when the previous candle's high exceeded the upper band, the current candle closed below the previous low, and the current low remains above the midline. This comprehensive logic ensures you're only getting signals when all conditions align for high-probability trades.

Advanced Signal Filtering: Eliminating False Positives

One common issue with basic Bollinger Bands strategies is generating signals after the mean reversion opportunity has already passed. To address this, our indicator includes intelligent filtering that checks whether the reversal has already occurred.

For long signals, we verify that the current candle's high hasn't yet reached the midline. This ensures we're entering trades with remaining upside potential rather than chasing moves that have already reached their target. Similarly, for short signals, we confirm that the current candle's low remains above the midline.

This filtering mechanism is crucial for practical trading success. Without it, traders often receive signals on candles where the reversion to the mean has already completed, leaving little profit potential and increased risk of reversal.

Signal Visualization and Chart Integration

The indicator displays buy and sell signals as arrows directly on your price chart. Green arrows appear below candles meeting our bullish criteria, while red arrows appear above candles satisfying bearish conditions. The arrows are sized for clear visibility without cluttering your chart analysis.

This visual approach allows for quick identification of potential trading opportunities across different timeframes. Whether you're scanning multiple charts or focusing on a single instrument, the arrow signals provide immediate clarity about when our reversal criteria are met.

Multi-Timeframe Application Strategies

The Bollinger Bands reversal indicator adapts automatically to any timeframe, making it versatile for different trading styles. Each timeframe offers unique advantages depending on your trading approach.

Day Trading Applications (1-15 minute charts)

On shorter timeframes, the indicator excels at identifying quick reversal opportunities during trending days. Day traders can use these signals for scalping opportunities or as confluence with other technical setups. The key is managing risk carefully, as shorter timeframes can produce more volatile price action.

Swing Trading Setups (Hourly to Daily charts)

Longer timeframes typically produce higher-quality signals with more substantial profit potential. Daily chart signals often coincide with significant support and resistance levels, providing natural targets for profit-taking. Swing traders can use these signals as primary entry triggers or as confirmation for existing analysis.

Risk Management and Trade Execution

Successful implementation of any reversal strategy requires disciplined risk management. The nature of mean reversion trading means you're entering positions against the prevailing momentum, making proper stop-loss placement critical.

Stop Loss Placement

For long positions, place stops below the low of the candle that triggered the signal. This provides a logical exit point if the reversal fails to materialize. For short positions, stops should be placed above the high of the trigger candle. This approach ensures you exit quickly if the extreme move continues beyond your entry point.

Profit Targets

The midline of the Bollinger Bands serves as a natural profit target for most trades. Since we're trading mean reversion, this level represents a logical point for partial or complete profit-taking. Advanced traders might consider scaling out of positions as price approaches the midline, taking partial profits while allowing some position to run toward the opposite band.

Position Sizing Considerations

Mean reversion strategies can experience periods of drawdown when trending markets produce consecutive failed signals. Consider using smaller position sizes relative to trend-following strategies, and avoid over-leveraging based on recent winning streaks.

Market Context and Environmental Factors

The effectiveness of Bollinger Bands reversal strategies varies significantly based on market conditions. Understanding when to apply this strategy most effectively can dramatically improve your results.

Ideal Market Conditions

Range-bound or consolidating markets provide the best environment for mean reversion strategies. During these periods, price tends to respect the statistical boundaries more consistently, leading to higher success rates for reversal signals.

Challenging Environments

Strong trending markets can produce extended moves that violate normal statistical boundaries for extended periods. During these conditions, consider reducing position sizes or combining reversal signals with trend-following indicators for additional confirmation.

Advanced Customization and Optimization

While the default Bollinger Bands settings (20-period simple moving average with 2 standard deviations) work well for most applications, certain market conditions or trading styles may benefit from adjustments.

Volatility Adjustments

In highly volatile markets, consider increasing the standard deviation multiplier to 2.5 or 3.0 to account for wider normal price ranges. Conversely, in low-volatility environments, reducing the multiplier to 1.5 or 1.8 can increase signal frequency while maintaining reliability.

Period Length Modifications

Shorter period lengths (10-15) create more responsive bands that generate more frequent signals, suitable for active day trading. Longer periods (30-50) produce more stable bands that filter out short-term noise, better suited for swing trading applications.

Integration with Other Technical Indicators

While the Bollinger Bands reversal indicator is powerful on its own, combining it with complementary technical analysis tools can enhance signal quality and provide additional confirmation.

Volume Confirmation

Adding volume analysis can help distinguish between high-quality and low-quality reversal signals. Signals accompanied by above-average volume often have higher success rates, as they indicate genuine institutional interest rather than random price movement.

Support and Resistance Confluence

Bollinger Bands reversal signals that occur near established support or resistance levels often produce more reliable results. This confluence of technical factors increases the probability of successful mean reversion.

Momentum Oscillators

RSI, Stochastic, or other momentum indicators can provide additional confirmation of overbought or oversold conditions. When these oscillators show extreme readings alongside Bollinger Bands signals, it strengthens the case for mean reversion.

Common Mistakes and How to Avoid Them

Ignoring Market Context

The biggest mistake traders make with reversal strategies is applying them indiscriminately across all market conditions. Always consider the broader trend and market environment before taking reversal trades.

Poor Risk Management

Mean reversion strategies can produce several losing trades in a row during trending markets. Ensure your position sizing and risk management can withstand these inevitable drawdown periods.

Chasing Signals

Wait for clear signal confirmation rather than anticipating potential setups. The indicator's filtering logic is designed to eliminate premature entries, so trust the system rather than trying to front-run signals.

Neglecting Exit Strategy

Having clear profit targets and stop-loss levels before entering trades is crucial. The midline provides a logical profit target, but consider market conditions and volatility when setting specific exit levels.

Performance Tracking and Continuous Improvement

Maintaining detailed records of your Bollinger Bands reversal trades helps identify patterns in performance and areas for improvement. Track success rates across different timeframes, market conditions, and underlying assets to optimize your approach.

Consider keeping statistics on signal frequency, average win/loss ratios, and maximum drawdown periods. This data helps you understand the strategy's characteristics and adjust position sizing and risk management accordingly.

Conclusion: Putting Theory into Practice

The Bollinger Bands reversal indicator provides a systematic approach to identifying and trading mean reversion opportunities. By combining statistical price boundaries with momentum confirmation, it filters out many of the false signals that plague simpler approaches.

Success with this strategy comes from understanding its strengths and limitations, applying proper risk management, and recognizing favorable market conditions. Start with smaller position sizes as you gain experience with the indicator's behavior, and gradually increase your commitment as you develop confidence in its application.

Remember that no single indicator guarantees profitable trades. The Bollinger Bands reversal strategy works best as part of a comprehensive trading approach that includes proper risk management, market analysis, and emotional discipline. Use it as a tool to identify potential opportunities, but always confirm signals with your broader market analysis before committing capital.

Bollinger Bands Reversal Indicator.ts
#Written by TOS Indicators 2023

#Home of the Volatility Box

#Indicator: Bollinger Bands Reversal Indicator

#Full Tutorial Link: tosindicators.com/indicators/bollinger-bands-reversal

#Defining Upper and Lower Bollinger Bands


// ... 36 more lines ...

Unlock This Code

Create a free account to access the full source code and download files.

Create Free Account Login
The Bollinger Bands reversal strategy identifies mean reversion opportunities by looking for two key conditions: (1) price breaking outside the Bollinger Bands (beyond 2 standard deviations), and (2) momentum confirmation through a reversal candle that closes above the previous high (for longs) or below the previous low (for shorts). This dual confirmation reduces false signals compared to simple band touches.
The indicator works on all timeframes but is most effective on 15-minute to daily charts. Day traders prefer 5-15 minute charts for quick scalping opportunities, while swing traders find better success on hourly to daily timeframes where signals have more follow-through potential. Higher timeframes typically produce higher-quality signals with less noise.
Place stops outside the trigger candle's range: below the low for long trades and above the high for short trades. This provides a logical exit if the reversal fails. The midline serves as a natural profit target since you're trading mean reversion. Risk-to-reward ratios are typically favorable since you're entering near extremes and targeting the middle.
The filtering logic checks if the mean reversion opportunity still exists by ensuring price hasn't already reached the midline. Without this filter, you'd get signals on candles where the reversion has already occurred, leaving little profit potential. This smart filtering eliminates late entries and improves overall signal quality.
Yes, you can adjust the standard deviation multiplier and period length. In high-volatility markets, increase the multiplier to 2.5-3.0 for wider bands. In low-volatility conditions, reduce to 1.5-1.8 for more signals. Shorter periods (10-15) create more responsive bands for day trading, while longer periods (30-50) work better for swing trading.
Range-bound and consolidating markets provide the best conditions for mean reversion trading. During strong trends, price can stay outside the bands for extended periods, creating consecutive losing trades. Use smaller position sizes in trending markets and consider combining with trend-following indicators for additional confirmation.
Add volume confirmation (above-average volume strengthens signals), support/resistance confluence (signals near key levels are more reliable), and momentum oscillators like RSI or Stochastic for overbought/oversold confirmation. Multiple confluences increase signal reliability and improve risk-to-reward ratios.
This indicator requires both band penetration AND momentum confirmation, significantly reducing false signals. Simple band touches often occur during trends and lead to losses, while our dual-confirmation approach waits for actual reversal momentum. The filtering logic also ensures the mean reversion opportunity still exists, avoiding late entries.

Here are some resources that you may find useful:

  • How to import an indicator into ThinkOrSwim (video tutorial)
Featured Tools:
Stock Volatility Box

Stock Volatility Box

Spot reversal zones across 600 stocks & ETFs.

  • Hourly & daily models
  • Powerful Live Scanner
  • Built for day traders
Futures Volatility Box

Futures Volatility Box

Pinpoint reversal zones in 10 major futures markets.

  • 5 models (incl. Scalper)
  • ThinkOrSwim & TradingView
  • SPX traders
ORB Setups

ORB Setups

Find the best Opening Range Breakout setups.

  • Powerful real-time scanner
  • Instant backtests
  • 2+ years data

Get Free Access

Create a free account for downloads and new tutorial alerts.

Create Free Account

More Tutorials Like This

Supply Demand Edge

Supply Demand Edge

Beginner-Friendly • 20 mins
Smarter MACD

Smarter MACD

Beginner-Friendly • 23 mins
Cash-Secured Put Calculator

Cash-Secured Put Calculator

Intermediate • 10 minutes

Ready to Trade With an Edge?

Join 40,000+ traders using institutional-grade tools for ThinkOrSwim.

Get the Bundle
TOS Indicators

Premium thinkorswim indicators, scans, and trading tools to help you trade smarter.

ThinkOrSwim Tools

  • Indicators
  • Scans
  • Backtesters
  • Dashboards
  • thinkScript
  • Browse All

Courses

  • Squeeze Course
  • Earnings Course
  • V-Shaped Reversals
  • Fibonacci Trading

Products

  • Futures Volatility Box
  • Stock Volatility Box
  • ORB Setups
  • Shop All

Guides

  • TTM Squeeze
  • Automated Trading
  • Volatility Trading
  • Opening Range Breakouts
  • Trade Reports
  • Contact Us

© 2026 TOS Indicators. All rights reserved.

Privacy Policy Terms of Service Disclaimer

The information contained on this website is solely for educational purposes, and does not constitute investment advice. The risk of trading in securities markets can be substantial. You must review and agree to our Terms of Service prior to using this site.

U.S. Government Required Disclaimer - Commodity Futures Trading Commission. Futures and options trading has large potential rewards, but also large potential risk. You must be aware of the risks and be willing to accept them in order to invest in the futures and options markets. Don't trade with money you can't afford to lose. This website is neither a solicitation nor an offer to Buy/Sell futures or options. No representation is being made that any account will or is likely to achieve profits or losses similar to those discussed on this website. The past performance of any trading system or methodology is not necessarily indicative of future results.

Individual results may vary, and testimonials are not claimed to represent typical results. All testimonials are by real people, and may not reflect the typical purchaser's experience, and are not intended to represent or guarantee that anyone will achieve the same or similar results.

TOS Indicator's Traders and employees will NEVER manage or offer to manage a customer or individual's options, stocks, currencies, futures, or any financial markets or securities account. If someone claiming to represent or be associated with TOS Indicator solicits you for money or offers to manage your trading account, do not provide any personal information and contact us immediately.

CFTC RULE 4.41 - HYPOTHETICAL OR SIMULATED PERFORMANCE RESULTS HAVE CERTAIN LIMITATIONS. UNLIKE AN ACTUAL PERFORMANCE RECORD, SIMULATED RESULTS DO NOT REPRESENT ACTUAL TRADING. ALSO, SINCE THE TRADES HAVE NOT BEEN EXECUTED, THE RESULTS MAY HAVE UNDER-OR-OVER COMPENSATED FOR THE IMPACT, IF ANY, OF CERTAIN MARKET FACTORS, SUCH AS LACK OF LIQUIDITY, SIMULATED TRADING PROGRAMS IN GENERAL ARE ALSO SUBJECT TO THE FACT THAT THEY ARE DESIGNED WITH THE BENEFIT OF HINDSIGHT. NO REPRESENTATION IS BEING MADE THAT ANY ACCOUNT WILL OR IS LIKELY TO ACHIEVE PROFIT OR LOSSES SIMILAR TO THOSE SHOWN.