Skip to main content Average Volume Stats 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 26 minutes ThinkOrSwim

Average Volume Stats

Learn to build a dynamic volume indicator for ThinkOrSwim that compares today's volume with historical averages using customizable timeframes and clean formatting.

Download Indicator
How to install in ThinkOrSwim →
Table of Contents
  • The Complete Guide to Building Average Volume Stats Indicators in ThinkOrSwim
  • Why Volume Statistics Matter for Trading Success
  • Understanding Volume Context and Timeframe Analysis
  • Step-by-Step Coding Tutorial: Building Your Volume Stats Indicator
  • Advanced Implementation Techniques
  • Practical Trading Applications
  • Customization and Extension Ideas
  • Common Implementation Pitfalls and Solutions
  • Integration with Other Technical Analysis Tools
  • Performance Monitoring and Optimization
  • Building Your Trading Edge
  • Conclusion: Mastering Volume-Based Trading Analysis

Build Your Ultimate Volume Analysis Tool in ThinkOrSwim

Stop guessing whether today’s volume is significant. Learn how to create a professional volume stats indicator that instantly shows how current trading activity compares to historical averages with clear visual signals.

This comprehensive ThinkScript tutorial teaches you to build a dynamic volume analysis system featuring:

  • Real-time daily volume tracking across any timeframe
  • Customizable average periods (30, 90, 180+ days) with user inputs
  • Automatic percentage calculations showing volume strength
  • Smart color coding: green for above-average, gray for below-average volume
  • Toggle between short format (191M) and long format (191,234,567) displays
  • Professional upper-panel labels that work on any chart timeframe

Perfect for traders who use volume confirmation in their strategies, this indicator transforms complex volume data into instant visual insights that help you spot high-conviction moves and avoid low-volume false breakouts.

The Complete Guide to Building Average Volume Stats Indicators in ThinkOrSwim

Volume analysis forms the cornerstone of professional trading, yet most platforms provide only basic volume displays that require mental calculations to determine significance. What if you could instantly see how today’s volume compares to historical averages, complete with percentage calculations and smart formatting?

This comprehensive tutorial teaches you to build a sophisticated average volume stats indicator that transforms raw volume data into actionable insights. You’ll learn not just the coding techniques, but the trading logic behind effective volume analysis and how to create tools that enhance your decision-making process.

Why Volume Statistics Matter for Trading Success

Professional traders understand that price movements without volume confirmation often lack conviction and sustainability. When you see a stock breaking out on twice its normal volume, that’s institutional money at work. When price moves on anemic volume, it’s often retail noise that quickly reverses.

Average volume stats help you identify several critical market conditions:

Institutional Activity Detection: When volume spikes to 200%+ of the 30-day average, it typically signals institutional accumulation or distribution. Your indicator will instantly highlight these moments with color coding and percentage displays.

False Breakout Prevention: Breakouts on below-average volume often fail. By seeing that today’s volume is only 60% of normal, you can avoid entering weak setups that lack conviction.

Trend Confirmation: Strong trends are typically accompanied by above-average volume in the direction of the move. Your stats indicator helps confirm trend strength by showing volume persistence over multiple timeframes.

Reversal Signal Enhancement: Volume exhaustion often precedes trend reversals. When a strong trend suddenly shows declining volume relative to its average, it may signal momentum loss.

Understanding Volume Context and Timeframe Analysis

The power of average volume stats lies in providing context that raw volume numbers cannot. Seeing “50 million shares traded” means nothing without knowing whether that’s high or low for the specific stock. Your indicator solves this by automatically calculating and displaying percentage relationships.

Short-term vs Long-term Averages: This tutorial uses dual timeframes (30-day and 90-day averages) to provide both recent and historical context. A stock might show 150% of 30-day average volume but only 80% of 90-day average, indicating recent quietness breaking with current activity.

Daily Volume Consistency: By tracking daily volume regardless of your chart timeframe, the indicator ensures consistent readings whether you’re viewing 1-minute or daily charts. This prevents confusion and maintains analytical continuity.

Percentage-Based Analysis: Converting volume relationships to percentages makes cross-stock comparison possible. A 200% volume day means the same thing for a penny stock or blue chip, enabling systematic scanning and analysis.

Step-by-Step Coding Tutorial: Building Your Volume Stats Indicator

Let’s walk through creating this indicator from scratch, understanding each concept and coding technique that makes it powerful and user-friendly.

Setting Up the Foundation: Accessing Daily Volume Data

The first challenge in building volume indicators is ensuring consistent data regardless of chart timeframe. Whether you’re viewing a 1-minute or weekly chart, you want daily volume data for meaningful comparisons.

Start by creating your new study in ThinkOrSwim’s Studies panel and naming it appropriately. Clear any default code and begin with the volume data foundation:

def vol = volume(period = day);

This line creates a definition that captures daily volume data specifically, overriding whatever timeframe your chart displays. The “period = day” parameter ensures consistency across all chart timeframes.

Test this foundation by creating a simple label to verify the data:

AddLabel(yes, vol, Color.Yellow);

Apply the indicator and confirm that the volume number matches ThinkOrSwim’s built-in volume display on a daily chart. This verification step ensures your data foundation is solid before building complexity.

Implementing Dynamic User Inputs

Hard-coding values limits flexibility and forces code edits for simple changes. Professional indicators use input variables that create user-friendly controls in the indicator settings.

Creating Length Inputs:

input length1 = 30;

input length2 = 90;

These input statements create slider controls in your indicator settings, allowing users to adjust the averaging periods without touching code. The default values (30 and 90) provide sensible starting points while enabling customization.

Building Average Calculations:

def average1 = Average(vol, length1);

def average2 = Average(vol, length2);

ThinkOrSwim’s built-in Average function calculates simple moving averages of your volume data over the specified periods. These definitions create the baseline comparisons for your percentage calculations.

Percentage Calculations and Analysis Logic

The core analytical power comes from converting raw volume relationships into easily interpreted percentages that show relative strength or weakness.

Computing Volume Ratios:

def percent1 = vol / average1;

def percent2 = vol / average2;

These calculations create decimal ratios where 1.0 equals 100% of average volume. Values above 1.0 indicate above-average volume, while values below 1.0 show below-average activity.

Converting to Readable Percentages:

AsPercent(percent1)

ThinkOrSwim’s AsPercent function converts decimal ratios to percentage format, automatically handling the multiplication by 100 and adding the percentage symbol for display purposes.

Smart Number Formatting System

Raw volume numbers often contain millions of shares with long decimal places that clutter displays. Professional indicators provide formatting options that balance precision with readability.

Creating Format Selection:

input numFormat = {default "Short", "Long"};

This input creates a dropdown menu allowing users to choose between short format (191M) and long format (191,234,567) displays. The bracket syntax defines the available options.

Implementing Switch Logic:

switch (numFormat) {

case "Short":

case "Long":

}

Switch statements provide clean logic for handling multiple format options. Each case defines different processing rules for the same underlying data.

Short Format Processing:

def volPlot = Round(vol / 1000000, 0);

For short format, divide volume by one million and round to zero decimal places. This converts 191,234,567 shares to 191, which displays as 191M when combined with appropriate labeling.

Long Format Preservation:

def volPlot = vol;

Long format simply passes through the original volume data without modification, preserving full precision for users who prefer complete detail.

Advanced Label Construction and Dynamic Text

Professional indicators provide rich information displays that combine multiple data points with dynamic formatting and smart color coding.

Building Composite Labels:

AddLabel(yes, "Volume: " + volPlot, Color.LIGHT_GRAY);

AddLabel(yes, length1 + " Day Avg: " + average1Plot + " | " + AsPercent(percent1), colorCondition);

These labels combine static text with dynamic variables and calculated values. The concatenation operator (+) joins text strings with variable values to create informative displays.

Dynamic Color Logic:

if percent1 <= 1 then Color.LIGHT_GRAY else Color.GREEN

Conditional color logic provides instant visual feedback. Gray indicates below-average volume (potentially weak moves), while green signals above-average volume (stronger conviction).

Upper Panel Declaration and Professional Presentation

Volume indicators work best when displayed prominently on price charts rather than buried in lower subpanels. The declare statement controls indicator placement.

Panel Control:

declare upper;

This declaration forces your indicator to display on the main price panel, ensuring volume stats appear prominently alongside price action where traders naturally focus their attention.

Advanced Implementation Techniques

Error Prevention Through Variable Naming: When creating multiple similar variables (volPlot, average1Plot, average2Plot), use descriptive suffixes to prevent naming conflicts and improve code maintainability.

Rounding for Clean Displays: Use Round() function strategically to eliminate unnecessary decimal places while preserving meaningful precision. Round(value, 0) for whole numbers, Round(value, 2) for two decimal places.

Input Validation: While not covered in this basic tutorial, professional indicators often include validation logic to ensure user inputs fall within reasonable ranges (e.g., length1 > 0 and length1 < 250).

Performance Optimization: Define calculations once and reuse variables rather than repeating complex calculations multiple times within label statements.

Practical Trading Applications

Breakout Confirmation: Before entering breakout trades, check your volume stats. Breakouts on 150%+ average volume have higher success rates than those on sub-100% volume.

Earnings Play Analysis: During earnings season, use volume stats to gauge institutional positioning. Unusual volume in the days leading up to earnings often signals informed money positioning.

Reversal Signal Enhancement: Combine volume stats with price action analysis. Reversal patterns accompanied by declining volume relative to recent averages may lack the conviction to follow through.

Sector Rotation Detection: Apply your indicator across multiple stocks within sectors to identify where institutional money is flowing. Consistent above-average volume across sector leaders signals potential rotation.

Customization and Extension Ideas

Adding Third Timeframe: Extend the indicator with a third averaging period (length3) for longer-term context. Many professional traders use 30/90/180-day combinations for comprehensive analysis.

Alert Integration: Add alert functionality that triggers when volume exceeds certain percentage thresholds (e.g., 200% of 30-day average).

Relative Volume Scoring: Create a composite score that weights short-term and long-term volume ratios to provide single-number volume strength ratings.

Market Hours Filtering: Enhance the indicator to focus only on regular trading hours volume, excluding pre-market and after-hours activity that might skew averages.

Common Implementation Pitfalls and Solutions

Variable Naming Conflicts: When building complex indicators, avoid reusing variable names. Each definition must have a unique identifier to prevent compilation errors.

Panel Placement Issues: Without the "declare upper" statement, volume indicators default to lower subpanels. Always include this declaration for price-chart integration.

Data Consistency Problems: Failing to specify "period = day" for volume data can cause inconsistent readings across different chart timeframes.

Color Logic Errors: Remember that percentage ratios are decimal values (1.5 = 150%), not whole numbers when writing conditional color logic.

Integration with Other Technical Analysis Tools

Moving Average Confluence: Combine volume stats with moving average analysis. Above-average volume during moving average bounces provides stronger support/resistance confirmation.

Chart Pattern Validation: Use volume stats to validate chart patterns. Triangles, wedges, and flag patterns breaking on above-average volume have higher success rates.

Momentum Indicator Synthesis: Pair volume stats with momentum indicators like RSI or MACD. Momentum divergences accompanied by declining volume ratios provide stronger reversal signals.

Options Flow Integration: For advanced traders, correlate volume stats with options unusual activity. Stocks showing both high volume ratios and unusual options flow deserve special attention.

Performance Monitoring and Optimization

Backtesting Integration: Use ThinkOrSwim's OnDemand feature to test your volume stats against historical price movements. Identify which volume thresholds provide the most reliable signals.

Market Condition Adaptation: During high volatility periods, consider adjusting your percentage thresholds. What constitutes "unusual" volume may change during market stress.

Symbol-Specific Calibration: Different stocks have different volume patterns. A biotech stock's volume behavior differs significantly from a utility stock's patterns.

Regular Review and Updates: Market structure evolves over time. Periodically review your averaging periods to ensure they still provide meaningful context.

Building Your Trading Edge

The real value of custom volume stats indicators lies not in the code itself, but in how you integrate them into a complete trading methodology:

Systematic Decision Making: Use volume stats as part of a checklist approach to trade evaluation. Require minimum volume thresholds for entry consideration.

Risk Management Integration: Adjust position sizes based on volume conviction. Higher volume ratios might justify larger positions within your risk parameters.

Market Context Awareness: Apply volume analysis across multiple timeframes and instruments to develop market-wide context for individual trading decisions.

Continuous Learning: Track which volume patterns lead to your most successful trades. Build this knowledge into systematic trading rules over time.

Conclusion: Mastering Volume-Based Trading Analysis

Building custom volume stats indicators in ThinkOrSwim empowers you with institutional-quality analysis tools that provide immediate insights into market participation and conviction levels. By understanding both the technical implementation and trading applications, you create a sustainable edge in identifying high-probability opportunities.

The indicator you've built does more than display numbers—it transforms raw market data into actionable intelligence that helps you avoid weak setups and identify strong conviction moves. As you become more experienced with volume analysis, you'll find countless ways to refine and enhance this foundation.

Remember that the most successful traders combine technical tools like volume analysis with sound risk management and systematic decision-making processes. Your custom volume stats indicator provides the data; your trading discipline determines the results.

Average Volume Stats Indicator.ts
#Home of the Volatility Box

#Indicator Name: Average Volume Stats

#Full tutorial here: tosindicators.com/indicators/average-volume

declare upper;

input numFormat = {default short, long};


// ... 43 more lines ...

Unlock This Code

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

Create Free Account Login
To create an average volume stats indicator in ThinkOrSwim, go to Studies > Create Study and start with def vol = volume(period = day); to capture daily volume data. Add input variables like input length1 = 30; for user controls, calculate averages with def average1 = Average(vol, length1);, and create percentage comparisons using def percent1 = vol / average1;. Use AddLabel() functions to display the results with conditional colors.
Use the period parameter in your volume definition: def vol = volume(period = day); This ensures your indicator always references daily volume data regardless of whether you're viewing 1-minute, 5-minute, or daily charts. Without this parameter, the indicator would show volume for whatever timeframe your chart displays, creating inconsistent readings.
Create user-selectable formatting with input numFormat = {default "Short", "Long"}; then use a switch statement to handle different formats. For short format, divide by 1,000,000 and round: volPlot = Round(vol / 1000000, 0); For long format, keep original values: volPlot = vol; This gives users control over display preferences.
Use conditional color logic in your AddLabel statements: if percent1 <= 1 then Color.LIGHT_GRAY else Color.GREEN. This makes labels gray when volume is at or below average (percent1 <= 1.0) and green when above average. You can customize thresholds and colors to match your trading style.
Use input statements at the top of your code: input length1 = 30; and input length2 = 90; These create slider controls in the indicator settings that users can adjust without editing code. Reference these variables in your calculations: def average1 = Average(vol, length1); to make the averages dynamic.
The declare upper; statement forces your indicator to display on the main price panel instead of the default volume subpanel. This keeps volume statistics visible alongside price action where traders naturally look, rather than buried in lower subpanels. Without this declaration, ThinkOrSwim automatically places volume-related indicators in the lower volume area.
Create percentage ratios with def percent1 = vol / average1; where values above 1.0 indicate above-average volume. Convert to readable percentages using AsPercent(percent1) in your labels. For example, if today's volume is 150% of the 30-day average, percent1 equals 1.5, and AsPercent(percent1) displays as "150.00%".
Yes, simply add additional input variables (input length3 = 180;), create corresponding average calculations (def average3 = Average(vol, length3);), compute percentages (def percent3 = vol / average3;), add formatting variables in your switch statement, and create additional labels. The pattern scales easily for 3, 4, or more averaging periods.

Here are some resources that you may find useful:

  • Relative Volume Indicator Tutorial
  • 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

Simple Momentum Signal For Short-Term Reversals

Simple Momentum Signal For Short-Term Reversals

Intermediate • 6 minutes
Smarter Earnings

Smarter Earnings

Intermediate • 46 mins
Supply Demand Edge

Supply Demand Edge

Beginner-Friendly • 20 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.