Volume Intensity
Use ChatGPT to build a volume indicator with multi-symbol tracking and volume intensity color-coding for quick, clear analysis.
Introduction
In this tutorial, you’ll learn to build a simple but effective Volume Intensity Indicator for ThinkOrSwim.
This indicator compares the volume of five selected symbols, highlighting trade opportunities when volume changes significantly.
We’ll create a special “volume intensity” ratio, which shows you exactly where each stock’s volume diverges significantly from its average.
And this will be the magic sauce that we build for all 5 symbols.
thinkScript Tutorial Overview
This indicator quickly reveals changes in volume strength, letting you visually confirm market activity and pinpoint entry and exit points. By comparing volume across multiple stocks, you can identify momentum shifts, potential reversals, and breakout setups.
Another reason this particular tutorial is useful is because we will be using the free version of ChatGPT to help us build this ThinkOrSwim indicator. We will layer on the initial logic for the first symbol, and then ask ChatGPT to do some of the heavy lifting for us and clone the code for the remaining process.
Volatility Box Invite
We are TOS Indicators.com, home of the Volatility Box.
The Volatility Box is our secret tool, to help us consistently profit from the market place. We’re a small team, and we spend hours every day, after the market close, doing nothing but studying thousands of data points to keep improving and perfecting the Volatility Box price ranges.
We have two different Volatility Boxes - a Futures Volatility Box and a Stock Volatility Box.
Futures Volatility Box - Trade Major Markets With an Edge
Designed For: Futures, Micro-Futures and Index Market Traders
Supported Models: Hourly Volatility Box models
Supported Markets: 10 Major Futures Markets
The Futures Volatility Box comes with:
- 5 Volatility Models for each market
- Support for 10 Futures Markets (/ES, /NQ, /YM, /RTY, /CL, /GC, /SI, /ZB, /HG, /NG)
- Video Setup Guide
- Trade Plan
- Access to all members-only resources, including Squeeze Course
Learn More About the Futures Volatility Box
Trade futures and micro futures with a consistent volatility edge
Stock Volatility Box - Powerful Web Based Volatility Platform
Designed For: Stock and Options Traders
Supported Models: Hourly and Daily Volatility Box models
Supported Markets: 10,000+ Stocks and ETFs (new markets added frequently)
A Stock Volatility Box membership includes access to:
- Live Scanner - A powerful scanner we've built from scratch, to scan 10,000 symbols every 2 seconds for new volatility breaches
- Dashboard - A quick and easy way to view daily volatility model levels online
- Short Interest Scanner - Short interest, Squeeze, and EMA data to find short squeezes
- Squeeze Course - All of our proprietary squeeze tools, including robust backtesters
- All Members Only Indicators - We don't nickel and dime you. Everything really is included.
- And much more!
Learn More About the Stock Volatility Box
Trade stocks and options with a consistent volatility edge
Step 1: Setting Up the Basic Inputs
We begin by defining the main inputs, including the volume calculation length and the five symbols you want to track. This makes it easy to customize which stocks the indicator will analyze.
declare lower;
input length = 20;
input symbol1 = "AAPL";
input symbol2 = "MSFT";
input symbol3 = "META";
input symbol4 = "GOOGL";
input symbol5 = "NVDA";
Explanation: The declare lower
command ensures that this indicator appears in the lower panel of ThinkOrSwim, separate from the price chart. Here, we set a length of 20 periods to average volume and define the five symbols we want to monitor. The user can adjust these symbols and length values as needed.
Step 2: Calculating Volume for the First Symbol
Now, let’s calculate the volume data for the first symbol, using Apple (AAPL) as an example. We’ll pull in volume data and calculate its average, which will act as a baseline for comparison.
def vol1 = volume(symbol = symbol1);
def volAvg1 = Average(vol1, length);
def intensity1 = vol1 / volAvg1;
Explanation: vol1
fetches the current volume for AAPL, while volAvg1
calculates its average over the last 20 periods (or whichever length you chose). The intensity variable, intensity1
, provides the ratio between today’s volume and the average, making it easy to spot spikes or drops.
Step 3: Creating the Plot Conditions
With the intensity ratio calculated, let’s create conditions to color-code the intensity of volume changes and plot this for AAPL.
plot volCondition1 = if !IsNaN(close) then 5 else Double.NaN;
volCondition1.SetPaintingStrategy(PaintingStrategy.POINTS);
volCondition1.SetLineWeight(3);
volCondition1.AssignValueColor(
if intensity1 > 2 then Color.LIGHT_GREEN else
if intensity1 > 1.5 then Color.GREEN else
if intensity1 > 1 then Color.DARK_GREEN else
if intensity1 > 0.75 then Color.DARK_RED else
if intensity1 > 0.5 then Color.RED else Color.LIGHT_RED
);
Explanation: We assign colors to represent different intensity levels, making it easy to spot volume spikes visually. The AssignValueColor
method changes the plot’s color based on intensity, with green indicating higher-than-average volume and red for lower-than-average volume.
Step 4: Adding Chart Bubbles for Symbol Identification
To keep track of which row corresponds to which symbol, let’s add chart bubbles labeled with the symbol’s ticker.
AddChartBubble(close > 0 and IsNaN(close[-1]), 5, symbol1,
if intensity1 > 2 then Color.LIGHT_GREEN else
if intensity1 > 1.5 then Color.GREEN else
if intensity1 > 1 then Color.DARK_GREEN else
if intensity1 > 0.75 then Color.DARK_RED else
if intensity1 > 0.5 then Color.RED else Color.LIGHT_RED
);
Explanation: This bubble appears only on the last valid bar, showing the ticker symbol of the first stock (AAPL). The color matches the intensity color coding, providing an additional visual cue for easy reference.
Step 5: Replicating for the Remaining Symbols
Now that we’ve set up the conditions and plot for AAPL, we can repeat these steps for the other four symbols. Each symbol will get its own volume, average, and intensity calculations, along with color-coded plots and bubbles.
def vol2 = volume(symbol = symbol2);
def volAvg2 = Average(vol2, length);
def intensity2 = vol2 / volAvg2;
plot volCondition2 = if !IsNaN(close) then 4 else Double.NaN;
volCondition2.SetPaintingStrategy(PaintingStrategy.POINTS);
volCondition2.SetLineWeight(3);
volCondition2.AssignValueColor(
if intensity2 > 2 then Color.LIGHT_GREEN else
if intensity2 > 1.5 then Color.GREEN else
if intensity2 > 1 then Color.DARK_GREEN else
if intensity2 > 0.75 then Color.DARK_RED else
if intensity2 > 0.5 then Color.RED else Color.LIGHT_RED
);
AddChartBubble(close > 0 and IsNaN(close[-1]), 4, symbol2,
if intensity2 > 2 then Color.LIGHT_GREEN else
if intensity2 > 1.5 then Color.GREEN else
if intensity2 > 1 then Color.DARK_GREEN else
if intensity2 > 0.75 then Color.DARK_RED else
if intensity2 > 0.5 then Color.RED else Color.LIGHT_RED
);
Note: Repeat the process for symbol3
, symbol4
, and symbol5
, adjusting the values and plot lines as needed.
Step 6: Adding Baseline and Reference Lines
To keep the chart organized, we’ll add two baseline lines. These lines help visually frame the indicator’s range on the lower panel, keeping everything clean and readable.
plot zero = 0;
zero.SetDefaultColor(Color.BLACK);
plot six = 6;
six.SetDefaultColor(Color.BLACK);
Explanation: These lines create boundaries for the indicator, helping you visually separate each symbol’s plot row. The zero
line sits at the bottom, while the six
line sits at the top.
Step 7: Running and Testing the Indicator
Once you’ve added the code for all symbols, apply it and test the indicator. Experiment with different length values and symbols to see how it behaves with various stocks and time frames.
Step 8: Customizing the Indicator
To fine-tune the indicator, try adjusting the following:
- Length: Change the
length
value for a more responsive or smoother volume average. - Color Thresholds: Modify the
AssignValueColor
thresholds to make color shifts more aggressive or subdued. - Symbols: Swap out the current symbols to track different stocks.
Conclusion
You’ve now created a Volume Intensity Indicator that highlights volume changes across multiple symbols, helping you spot key trading opportunities based on volume. This tool can be a valuable addition to your ThinkOrSwim setup.
downloads
Download the Volume Intensity Indicator for ThinkorSwim.
The download contains a STUDY.ts file, which you can directly import into your ThinkOrSwim platform.
Download Indicator
Download the Volume Intensity Indicator for ThinkorSwim.
The download contains a STUDY.ts file, which you can directly import into your ThinkOrSwim platform.