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!
#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 ...Here are some resources that you may find useful: