Skip to main content Advance Decline Trading System 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 11 mins ThinkOrSwim

Cumulative Advance Decline Trading System

Build an introductory trading system using the Advance Decline line, by taking a basic indicator and extracting patterns and signals.

Download Indicator
How to install in ThinkOrSwim →
Table of Contents
  • Why the Cumulative Advance Decline is Useful in a Trading System
  • Building a Cumulative Advance Decline Trading System
  • Conclusion

Introduction

The Cumulative Advance Decline Indicator tracks the cumulative difference between advancing and declining stocks, giving you a perspective on market breadth.

  • When advances outpace declines, the indicator rises, signaling bullish sentiment.
  • Conversely, when declines dominate, it drops, suggesting bearish momentum.

You can use this indicator to gauge the overall market direction and spot potential turning points by examining divergence between the cumulative line and price action.

Why the Cumulative Advance Decline is Useful in a Trading System

With the Cumulative Advance Decline, you’re able to spot broader market trends, beyond the movements of individual stocks. For example, when a market rally is accompanied by a rising cumulative line, it strengthens the bullish case. Conversely, if the cumulative line is falling during a rally, it might signal weakness and a potential reversal. By integrating the Cumulative Advance Decline into your trading system, you’re able to monitor both individual tickers and the overall market to better time entries and exits.

Building a Cumulative Advance Decline Trading System

Step 1: Setting Up Your Workspace

To get started, open ThinkOrSwim and navigate to the Studies section. Click on ‘Create’ to start a new custom study. Name this study something meaningful, like Cumulative Advance Decline System. For this tutorial, we’ll work with six market symbols, but feel free to adjust the number to suit your needs.

Step 2: Input Your Symbols

In this example, we’re focusing on six market symbols. Use the input function to define each symbol as shown below. This setup allows you to easily adjust symbols in the future directly from the study settings.


input symbol_1 = "/NQ:XCME";
input symbol_2 = "/ES:XCME";
input symbol_3 = "/YM:XCME";
input symbol_4 = "/RTY:XCME";
input symbol_5 = "/ZB:XCBT";
input symbol_6 = "/MNQ:XCME";

Step 3: Defining the Advance/Decline Logic

Now, we’ll determine whether each symbol is advancing or declining based on the previous close. Use the following code for each symbol to identify if it has increased or decreased in value compared to the previous bar.


def symbol1 = close(symbol_1);
def symbol11 = close(symbol_1)[1];
def symbol1a = symbol1 > symbol11;
def symbol1b = symbol1 < symbol11;

Repeat this for each symbol, changing the variable names accordingly. For example, replace symbol1 with symbol2 and so on.

Step 4: Calculating the Cumulative Advance Decline Line

With the advance/decline status defined for each symbol, you can now calculate the Cumulative Advance Decline Line by summing up the individual results. The following code calculates the line and plots it:


plot advDecLine = TotalSum((symbol1a - symbol1b) + (symbol2a - symbol2b) + (symbol3a - symbol3b) + (symbol4a - symbol4b) + (symbol5a - symbol5b) + (symbol6a - symbol6b));
AddChartBubble(GetYYYYMMDD() >= anchorDate, 0, advDecLine, Color.Yellow);

Step 5: Adding a Moving Average for Trend Identification

Adding a moving average to your cumulative line can help you identify the broader trend. Use the following code to calculate and plot a 50-period moving average of the advance-decline line:


plot advDecLineAvg = Average(advDecLine, 50);

Step 6: Adding Buy and Sell Signals

To make this a complete trading system, let’s add buy and sell signals based on crossovers of the Cumulative Advance Decline Line and its moving average, with CCI confirmation. A bullish signal occurs when the line crosses above the average with CCI above 100, while a bearish signal appears when it crosses below with CCI under -100. Here’s the code:


plot bearishCrossOverSignal = if advDecLine < advDecLineAvg and advDecLine[1] >= advDecLineAvg and CCI() <= -100 then advDecLineAvg else Double.NaN; plot bullishCrossOverSignal = if advDecLine > advDecLineAvg and advDecLine[1] <= advDecLineAvg and CCI() >= 100 then advDecLineAvg else Double.NaN;
bearishCrossOverSignal.SetPaintingStrategy(PaintingStrategy.ARROW_DOWN);
bullishCrossOverSignal.SetPaintingStrategy(PaintingStrategy.ARROW_UP);

Step 7: Styling the Arrows

To make the signals easier to spot, you can increase the arrow weight. Here’s how:


bearishCrossOverSignal.SetLineWeight(3);
bullishCrossOverSignal.SetLineWeight(3);

Now, your chart should display up and down arrows on the Cumulative Advance Decline Line whenever a bullish or bearish crossover occurs.

Conclusion

You’ve now built a powerful Cumulative Advance Decline Trading System that leverages the market breadth to provide you with trade signals. Feel free to experiment with different tickers, adjust the moving average period, or add other conditions to enhance the indicator further.

As you trade with this system, remember to observe how well it tracks major market shifts and how it performs under different market conditions.

With these insights, you can fine-tune the system to suit your trading style even more.

Hope you found this tutorial helpful. Thanks for watching, and as always, good luck trading!

Advance Decline Trading System.ts
#Written by TOS Indicators 2020

#Home of the Volatility Box

#Indicator: Anchored Cumulative Advance Decline

#References TTM_Squeeze source code in TOS and Edge Signals Source Code

#Full Course Link: tosindicators.com/squeeze-course/


// ... 77 more lines ...

Unlock This Code

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

Create Free Account Login
An anchored cumulative advance decline trading system tracks multiple stocks starting from a specific date (like earnings or Fed meetings) and maintains a running total of advancing vs declining stocks. It generates buy/sell signals when the cumulative line crosses above or below its 50-period average, confirmed by CCI momentum readings above +100 (bullish) or below -100 (bearish).
Anchoring to a specific date allows you to measure group performance from significant market events like earnings, Fed meetings, or economic announcements. This eliminates historical noise and provides clearer trend identification from meaningful starting points. You can track how your stock group performed since a specific catalyst rather than using arbitrary historical data.
Use the startDateYyyyMmDd input parameter in YYYYMMDD format. For example, 20201201 sets December 1, 2020 as the anchor date. The system uses GetYYYYMMDD() >= startDateYyyyMmDd to activate calculations only after this date. Choose dates that coincide with significant market events for more meaningful analysis.
The system calculates separate Boolean values (symbol1a, symbol1b, etc.) for advancing and declining stocks to create a more precise cumulative calculation. Using (symbol1a - symbol1b) gives +1 for advancing, -1 for declining, and 0 for unchanged, providing accurate directional scoring for each stock in the group without bias from price magnitude.
CCI (Commodity Channel Index) confirmation filters out weak crossover signals by requiring momentum support. The system uses the default CCI() function which applies CCI to the primary chart data. CCI readings above +100 indicate strong bullish momentum, while readings below -100 suggest strong bearish momentum, significantly reducing false signals.
The 50-period average provides good balance for most trading styles. For day trading, try 20-30 periods for faster signals. For swing trading, 50-100 periods work well. For position trading, consider 100+ periods. The key is matching the average period to your trading timeframe while maintaining enough smoothing to filter noise.
Yes, the system includes six input variables (symbol_1 through symbol_6) that default to FB, AMZN, AAPL, NFLX, GOOG, and MSFT. You can modify these through the indicator properties after applying it to your chart. Choose stocks that represent your trading focus or sector for more relevant signals.
The declare lower; statement forces the indicator to display in the lower subgraph rather than overlaying on the price chart. This is appropriate because cumulative advance decline values operate on a different scale than stock prices. The lower pane allows clear visualization of the cumulative line, average, and signal arrows without interfering with price analysis.

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

Cumulative TICK

Cumulative TICK

Beginner • 21 minutes
Commodities Tracker

Commodities Tracker

Beginner • 15 minutes
Edge Signals

Edge Signals

Beginner-Friendly • 14 mins

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.