Skip to main content Dynamic RSI Indicator For ThinkOrSwim 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
Intermediate 48 mins ThinkOrSwim

Dynamic RSI

Learn how to create a powerful Dynamic RSI indicator in ThinkOrSwim that combines traditional RSI with Bollinger Bands, automatic trend lines, and squeeze detection for superior overbought/oversold signals and trend identification.

Download Indicator
How to install in ThinkOrSwim →
Table of Contents
  • The Complete Guide to Building a Dynamic RSI Indicator in ThinkOrSwim
  • Understanding the Core Components
  • Signal Generation and Filtering Logic
  • Step-by-Step Coding Tutorial
  • Customization and Integration

Introduction

In this tutorial, I’ll show you how to build a Dynamic RSI Indicator using thinkScript code for the ThinkOrSwim (TOS) trading platform. We’ll leverage code snippets, and our own logic, to create a powerful RSI indicator that adapts to market volatility.

  • RSI with Bollinger Bands for dynamic overbought/oversold levels
  • Automatic trend line detection for objective support and resistance
  • Squeeze detection for compression and breakout identification
  • Dynamic yellow average line for trend confirmation
  • Upper and lower study configuration for comprehensive analysis

The Dynamic RSI indicator combines Bollinger Bands, trend lines, and various RSI metrics. The Bollinger Bands on the RSI chart help gauge overbought and oversold conditions, while trend lines provide support and resistance levels for potential trading signals.

I’ll take you through, step-by-step, how to build the Dynamic RSI indicator for ThinkOrSwim below.

The Complete Guide to Building a Dynamic RSI Indicator in ThinkOrSwim

The Relative Strength Index (RSI) is one of the most widely used technical indicators, but in its standard form, it often generates too many false signals and lacks the nuanced analysis needed for today’s complex markets. The Dynamic RSI indicator changes that by layering additional analytical components that transform the basic RSI into a sophisticated trading system capable of identifying institutional activity and market reversals with remarkable precision.

This tutorial takes you through the complete process of building Keith’s Dynamic RSI indicator, a system that has been refined through thousands of hours of real trading and market observation. Unlike static indicators that use fixed parameters, this Dynamic RSI adapts to market conditions, providing more reliable signals and reducing false breakouts that plague traditional RSI analysis.

Understanding the Core Components

The Dynamic RSI system consists of five integrated components that work together to create a comprehensive trading tool. Each component serves a specific purpose and contributes unique information to your trading decisions.

The foundation starts with the traditional RSI calculation, but we enhance it with a dynamic yellow average line that provides smoother trend identification. This yellow line acts as a filter, helping distinguish between temporary price fluctuations and meaningful trend changes. When this dynamic average crosses above or below traditional overbought and oversold levels, it signals that institutional money is actively moving the market.

Bollinger Bands applied to the RSI create adaptive overbought and oversold zones that adjust to market volatility. Unlike fixed RSI levels at 70 and 30, these Bollinger Bands expand during volatile periods and contract during quiet markets, providing more accurate reversal signals. When the RSI breaks outside these bands, it indicates extreme conditions that often precede significant price movements.

Automatic trend line detection removes the subjectivity from traditional trend line analysis. Using Mobius’s proven algorithm, the indicator automatically draws trend lines on the RSI, identifying support and resistance levels that would be impossible to spot manually in real-time. These trend lines provide objective entry and exit points based on mathematical calculations rather than subjective interpretation.

Squeeze detection monitors the compression between the upper and lower Bollinger Bands on the RSI. When these bands compress, it indicates a period of low volatility that often precedes explosive price movements. The squeeze dots provide early warning of impending breakouts, allowing you to position before the crowd recognizes the setup.

Signal Generation and Filtering Logic

The Dynamic RSI generates multiple types of signals, each serving different trading objectives. Understanding how to interpret and combine these signals is crucial for successful implementation.

Bollinger Band breakthrough signals occur when the RSI breaks above the upper band or below the lower band. These signals indicate extreme momentum conditions that often lead to price reversals. For bullish signals, the system requires the RSI to fall below the lower Bollinger Band while ensuring the lower band itself is below the 45 level and the RSI is in oversold territory below 30. This multi-condition approach significantly reduces false signals.

Bearish signals require the RSI to break above the upper Bollinger Band while the upper band is above 55 and the RSI is in overbought territory above 70. These additional filters ensure that signals only generate during meaningful extreme conditions rather than temporary fluctuations.

Dynamic average crossover signals provide trend confirmation and reversal warnings. When the yellow dynamic average crosses above the overbought level (70), it indicates the market is entering a potentially unstable bullish phase. The system also tracks when the dynamic average exits these extreme zones, providing valuable information about trend sustainability.

Step-by-Step Coding Tutorial

Now let’s walk through the complete process of building this Dynamic RSI indicator from the ground up. By building it step-by-step, you’ll understand exactly how the indicator functions and be able to customize it for your specific needs.

Step 1: Setting Up Global Variables and Input Parameters

We start by declaring this as a lower study and setting up all the input parameters that control the indicator’s behavior:

declare lower;
input length = 14;
input over_Bought = 70;
input over_Sold = 30;
input price = close;
input averageType = AverageType.WILDERS;
input showBreakoutSignals = no;
input Volatility_Band = 14;
input STDEV_Multiplier = 2;
input RSI_Period = 14;
input RSI_Price_Line = 2;

The declare lower statement tells ThinkOrSwim to display this indicator in the lower study area. The input variables provide flexibility for different trading styles – day traders might use shorter periods while swing traders prefer longer settings.

Step 2: Building the Core RSI Calculations

Next, we calculate the RSI using a more flexible approach that allows different moving average types:

def NetChgAvg = MovingAverage(averageType, price - price[1], length);
def TotChgAvg = MovingAverage(averageType, AbsValue(price - price[1]), length);
def ChgRatio = if TotChgAvg != 0 then NetChgAvg / TotChgAvg else 0;

def DYNRSI = reference RSI(RSI_Period);
def Price1 = if averageType == AverageType.SIMPLE then Average(DYNRSI, RSI_Price_Line) else ExpAverage(DYNRSI, RSI_Price_Line);
def SDBB = StDev(DYNRSI, Volatility_Band);

These calculations create the foundation for our dynamic RSI. The DYNRSI references the standard RSI calculation, while SDBB calculates the standard deviation for our Bollinger Bands.

Step 3: Plotting RSI and Reference Levels

Now we plot the actual RSI line along with reference levels and the crucial dynamic yellow average line:

plot RSI = 50 * (ChgRatio + 1);
plot MiddleLine = 50;
plot MiddleLine1 = 70;
plot MiddleLine2 = 30;

plot DYNAverage = Average(DYNRSI, Volatility_Band);
DYNAverage.SetDefaultColor(Color.YELLOW);
DYNAverage.SetLineWeight(2);

The yellow dynamic average line is crucial – it smooths out RSI noise and provides more reliable trend signals than the raw RSI line.

Step 4: Creating Dynamic Bollinger Bands

The Bollinger Bands create adaptive overbought and oversold zones that adjust to market volatility:

plot UpperBollinger = DYNAverage + STDEV_Multiplier * SDBB;
UpperBollinger.SetDefaultColor(Color.RED);
plot LowerBollinger = DYNAverage - STDEV_Multiplier * SDBB;
LowerBollinger.SetDefaultColor(Color.GREEN);

These bands use the dynamic average as the middle line rather than a simple moving average. When the RSI breaks outside these bands, it indicates extreme conditions.

Step 5: Adding Signal Generation Logic

We add breakthrough signal logic with multiple filters to reduce false positives:

plot BullSignal = if RSI <= LowerBollinger and 
                      LowerBollinger <= 45 and 
                      RSI = UpperBollinger and 
                      UpperBollinger >= 55 and 
                      RSI >= 70 
                  then 1 else 0;

BullSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
BearSignal.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);

The bull signal requires the RSI to break below the lower Bollinger Band while ensuring we’re in truly oversold conditions. These multiple filters dramatically reduce false signals.

Step 6: Implementing Dynamic Average Entry/Exit Tracking

One of Keith’s key insights was tracking when the dynamic average enters and exits extreme zones:

def SuperOverbought = DYNAverage crosses above over_Bought;
def SuperOversold = DYNAverage crosses below over_Sold;
def SuperOverboughtExit = DYNAverage crosses below over_Bought;
def SuperOversoldExit = DYNAverage crosses above over_Sold;

AddChartBubble(SuperOverbought and !SuperOverbought[1], close, "Enter Super OB", Color.LIGHT_RED);
AddChartBubble(SuperOversold and !SuperOversold[1], close, "Enter Super OS", Color.LIGHT_GREEN);
AddChartBubble(SuperOverboughtExit and !SuperOverboughtExit[1], close, "Exit Super OB", Color.RED);
AddChartBubble(SuperOversoldExit and !SuperOversoldExit[1], close, "Exit Super OS", Color.GREEN);

These chart bubbles provide context about market momentum and potential trend changes, with color coding to help you quickly identify signal types.

Step 7: Adding Squeeze Detection

The squeeze detection monitors when the Bollinger Bands compress, indicating low volatility that often precedes explosive moves:

def BBDistance = if UpperBollinger - LowerBollinger <= 10 then 1 else 0;
plot squeeze = if BBDistance then 50 else Double.NaN;
squeeze.SetPaintingStrategy(PaintingStrategy.POINTS);
squeeze.SetLineWeight(4);
squeeze.SetDefaultColor(Color.RED);

When the distance between the Bollinger Bands falls below 10 points, red dots appear warning of impending volatility expansion.

Step 8: Incorporating Automatic Trend Lines

The automatic trend line system uses Mobius's proven inertia-based algorithm:

input TrendLineLength1 = 150;
input TrendLineLength2 = 80;
input TrendLineLength3 = 40;

def Inertia1 = InertiaAll(RSI, TrendLineLength1);
def Inertia2 = InertiaAll(RSI, TrendLineLength2);
def Inertia3 = InertiaAll(RSI, TrendLineLength3);

def TL_Bull2 = Inertia2 - (HighestAll(AbsValue(Inertia2 - RSI)) * 0.8);
def TL_Bear2 = Inertia2 + (HighestAll(AbsValue(Inertia2 - RSI)) * 0.8);

plot TrendLine2a = TL_Bull2;
plot TrendLine2b = TL_Bear2;

This creates multiple trend lines with different sensitivities. We focus on the medium-length trend lines as they provide the best balance between reliability and signal frequency.

Step 9: Adding Trend Line Signal Detection

Finally, we add logic to detect when the RSI bounces off or breaks through the trend lines:

def trendLineSignalLong = if RSI >= TrendLine2b and RSI[1] < TrendLine2b then 1 else 0;
def trendLineSignalShort = if RSI  TrendLine2a then 1 else 0;

AddChartBubble(trendLineSignalLong and !trendLineSignalLong[1], TrendLine2b, "Long", Color.LIGHT_GREEN);
AddChartBubble(trendLineSignalShort and !trendLineSignalShort[1], TrendLine2a, "Short", Color.LIGHT_RED);

These chart bubbles appear when the RSI touches the trend lines, providing clear entry signals for trend line bounces.

Step 10: Creating the Upper Study Version

For the upper study that appears on your price chart, we simplify the display to show only the most critical signals:

declare upper;

# Copy the same calculation logic here but change plots to definitions

plot BullishArrow = if (RSI breakthrough conditions met) then close else Double.NaN;
plot BearishArrow = if (RSI breakthrough conditions met) then close else Double.NaN;
plot SqueezeUpper = if BBDistance then close else Double.NaN;

BullishArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_UP);
BearishArrow.SetPaintingStrategy(PaintingStrategy.BOOLEAN_ARROW_DOWN);
SqueezeUpper.SetPaintingStrategy(PaintingStrategy.POINTS);

The upper study focuses on actionable signals without cluttering your price chart. Arrows appear when breakthrough conditions are met, and squeeze dots warn of volatility compression.

Customization and Integration

Once you have the basic indicator built, you can customize it for your specific trading style. For day trading, consider reducing the RSI period to 8-10 and using shorter Bollinger Band periods. Swing traders typically prefer longer periods that filter out noise.

The Dynamic RSI works exceptionally well as a confirmation tool with other trading systems. When combined with volatility-based systems like the Volatility Box, Dynamic RSI signals help validate trading opportunities and improve entry timing. Keith's research suggests that 4-minute charts provide an optimal balance between signal frequency and accuracy for day trading.

The Dynamic RSI represents a significant evolution beyond traditional RSI analysis. By combining multiple analytical layers, it creates a comprehensive trading system that adapts to changing market conditions. Start by implementing the basic version and familiarize yourself with the signals it generates before experimenting with customization options to optimize it for your trading style.

Dynamic RSI Indicator.ts
### Includes code written by Keith C., Mobius, and TOS Indicators

### Last Update: 11/3/2019

### Full Tutorial Available Here: https://www.tosindicators.com/indicators/dynamic-rsi

### Global Variables ###

declare lower;


// ... 171 more lines ...

Unlock This Code

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

Create Free Account Login
Start by setting up global variables and input parameters using declare lower and input statements. Then build the core RSI calculations with NetChgAvg and TotChgAvg variables. Add the dynamic yellow average line using Average(DYNRSI, Volatility_Band), plot Bollinger Bands around this average, and finally incorporate automatic trend lines using Mobius's inertia-based algorithm. Each step builds on the previous one to create the complete system.
The Dynamic RSI combines five key components: traditional RSI with a smoothing yellow average line, adaptive Bollinger Bands that adjust to volatility, automatic trend line detection for objective support/resistance, squeeze detection for volatility compression, and multi-condition signal filtering. This creates a comprehensive system that adapts to market conditions rather than using fixed parameters.
Use Mobius's inertia-based algorithm with three different lengths (150, 80, 40 periods). Calculate inertia values using InertiaAll(RSI, TrendLineLength), then create bull and bear trend lines using the formula Inertia - (HighestAll(AbsValue(Inertia - RSI)) * 0.8). Plot these as trend lines and add chart bubbles to detect when RSI touches the lines for objective trading signals.
For day trading, use RSI period 8-10, Bollinger Band period 10-12, and trend line lengths 100/60/30 for more sensitive signals. For swing trading, use RSI period 21, Bollinger Band period 20, and trend line lengths 200/120/60 for more stable signals. Keith recommends 4-minute charts for optimal balance between signal frequency and accuracy.
Squeeze detection monitors the distance between upper and lower Bollinger Bands on the RSI. When this distance falls below 10 points (customizable), red dots appear indicating compression. This warns of low volatility periods that often precede explosive price movements. The squeeze works on the RSI level rather than price, providing earlier signals than traditional price-based squeeze indicators.
Bullish signals require: RSI breaks below lower Bollinger Band AND lower band is below 45 AND RSI is below 30. Bearish signals require: RSI breaks above upper Bollinger Band AND upper band is above 55 AND RSI is above 70. These multiple conditions filter out false signals and ensure arrows only appear during extreme, high-probability setups.
Create two separate indicators: Lower study shows complete RSI analysis with all lines, bands, and trend lines visible. Upper study uses declare upper and plots only arrows and squeeze dots on the price chart using the same calculation logic but simplified plotting. This keeps price charts clean while providing full analysis in the lower study window.
Yes, extensively. Adjust RSI_Period (8-25), Volatility_Band (10-40), STDEV_Multiplier (1.5-3.0), and trend line lengths for different sensitivities. Change colors using SetDefaultColor() for all plot elements. Modify the squeeze threshold (default 10) and breakthrough signal thresholds (45/55 levels) to fine-tune for your trading style and market conditions.

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

Parabolic SAR

Parabolic SAR

Intermediate • 65 minutes
Pre-Earnings Analysis

Pre-Earnings Analysis

Beginner • 33 minutes
Option Chain Relative Value

Option Chain Relative Value

Advanced • 40 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.