Skip to main content Multiple TimeFrame Moving Averages 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 21 minutes ThinkOrSwim

Multiple Time Frame Moving Averages

Learn how to create multiple time frame moving averages in ThinkOrSwim using ThinkScript aggregation periods to display daily, hourly, and intraday moving averages on a single chart for enhanced technical analysis.

Download Indicator
How to install in ThinkOrSwim →
Table of Contents
  • Multiple Time Frame Moving Averages in ThinkOrSwim
  • Why Multiple Time Frame Moving Averages Matter
  • Understanding Aggregation Periods in ThinkScript
  • The Four Moving Averages Strategy
  • Building the Indicator: Step-by-Step Implementation
  • Advanced Implementation Techniques
  • Practical Trading Applications
  • Customization and Enhancement Options
  • Common Implementation Challenges and Solutions
  • Testing and Validation
  • Best Practices for Multi-Time Frame Analysis
  • Integration with Trading Strategies
  • Conclusion: Maximizing Your Trading Efficiency

Build Multiple Time Frame Moving Averages in ThinkOrSwim

Discover how to build powerful multiple time frame moving averages that display trend analysis from four different time periods on a single chart using advanced ThinkScript techniques.

This advanced tutorial teaches you to create a dynamic indicator that displays:

  • Daily 10-period Simple Moving Average
  • 1-Hour 50-period Exponential Moving Average
  • 30-Minute 30-period Exponential Moving Average
  • 15-Minute 20-period Exponential Moving Average

Perfect for traders who want to analyze multiple time frame confluences without cluttering their workspace with numerous charts. This technique is especially valuable for laptop traders and anyone looking to streamline their technical analysis process.

Multiple Time Frame Moving Averages in ThinkOrSwim

Multiple time frame moving averages represent one of the most sophisticated approaches to technical analysis, allowing traders to simultaneously view trend dynamics across different time horizons on a single chart. This powerful technique eliminates the need to constantly switch between multiple charts while providing comprehensive trend analysis from daily down to 15-minute time frames.

In this comprehensive guide, you’ll learn how to create a sophisticated ThinkScript indicator that displays moving averages from four different time frames simultaneously, automatically adjusting based on your current chart time frame to prevent errors and maximize functionality.

Why Multiple Time Frame Moving Averages Matter

Professional traders understand that trends exist on multiple time frames simultaneously. A stock might be in a strong uptrend on the daily chart while experiencing a short-term pullback on the 15-minute chart. By viewing moving averages from different time frames on one chart, you can:

Identify trend confluence: When moving averages from multiple time frames align, it often signals stronger trend continuation or reversal setups. For example, if price is above the daily, hourly, and 30-minute moving averages, it suggests a robust bullish environment across multiple time frames.

Spot trend divergences early: When shorter time frame moving averages start diverging from longer ones, it can signal potential trend changes before they become obvious on individual time frame charts.

Improve entry and exit timing: Use longer time frame moving averages to determine overall trend direction, while shorter time frame averages help fine-tune entry and exit points.

Reduce analysis time: Instead of flipping between multiple charts, you get a comprehensive view of trend dynamics at a glance, making your trading decisions faster and more informed.

Understanding Aggregation Periods in ThinkScript

The foundation of multi-time frame analysis in ThinkOrSwim is the aggregation period concept. Think of aggregation periods as ThinkScript’s way of accessing data from different time frames. When you specify an aggregation period, you’re telling ThinkOrSwim to pull price data from that specific time frame, regardless of what chart you’re currently viewing.

For example, using `close(period = “Day”)` on a 5-minute chart will pull the daily closing prices, allowing you to calculate a daily moving average and display it on your intraday chart. This is incredibly powerful because it lets you overlay longer-term trend information on shorter-term charts.

However, there’s a crucial limitation: you can only access data from time frames equal to or greater than your current chart time frame. You cannot access 1-minute data while viewing a 5-minute chart, but you can access daily data from any intraday chart.

The Four Moving Averages Strategy

Our indicator combines four strategically chosen moving averages from different time frames:

Daily 10-period SMA: This represents the longer-term trend direction and acts as a major support/resistance level. The 10-period daily SMA is responsive enough to capture trend changes while filtering out short-term noise.

1-Hour 50-period EMA: This intermediate time frame average helps identify the prevailing trend for swing trading opportunities. The 50-period length provides a good balance between responsiveness and stability.

30-Minute 30-period EMA: This shorter intermediate average is excellent for day trading setups and identifying short-term trend reversals within the larger trend context.

15-Minute 20-period EMA: The most responsive average in our setup, perfect for precise entry and exit timing, especially for scalping and quick day trades.

This combination provides a comprehensive view of trend dynamics across multiple time horizons, from long-term positioning down to short-term execution.

Building the Indicator: Step-by-Step Implementation

Creating a robust multi-time frame moving average indicator requires careful planning to handle ThinkOrSwim’s aggregation period limitations. We’ll build this indicator using Boolean conditional logic to ensure it works flawlessly across all time frames.

Step 1: Define Input Variables

Start by creating input variables for each moving average length. This makes the indicator customizable and allows users to adjust the periods based on their trading style:

input dailySMALength = 10;
input oneHourEMALength = 50;
input thirtyMinuteEMALength = 30;
input fifteenMinuteEMALength = 20;

These inputs appear in the study’s settings dialog, making it easy to modify the moving average periods without editing the code.

Step 2: Initialize Plot Variables

Next, declare the plot variables that will display each moving average. These are initialized here but defined within conditional blocks to prevent aggregation period errors:

plot SMAOneDayChart;
plot EMAOneHourChart;
plot EMAThirtyMinuteChart;
plot EMAFifteenMinuteChart;

Step 3: Implement Conditional Logic

This is where the magic happens. We use `getAggregationPeriod()` to determine the current chart time frame and conditionally define which moving averages to display. Starting with the largest time frame first optimizes performance:

For time frames between 1 hour and 2 days, only the daily moving average is accessible:

if getAggregationPeriod() > AggregationPeriod.Hour and getAggregationPeriod() < AggregationPeriod.Two_Days then {
    SMAOneDayChart = SimpleMovingAvg(close(period = "Day"), dailySMALength);
    EMAOneHourChart = Double.nan;
    EMAThirtyMinuteChart = Double.nan;
    EMAFifteenMinuteChart = Double.nan;
}

For hourly and above time frames, daily and hourly moving averages are available:

else if getAggregationPeriod() >= AggregationPeriod.Hour then {
    SMAOneDayChart = SimpleMovingAvg(close(period = "Day"), dailySMALength);
    EMAOneHourChart = ExpAverage(close(period="1 hour"), oneHourEMALength);
    EMAThirtyMinuteChart = Double.nan;
    EMAFifteenMinuteChart = Double.nan;
}

This pattern continues for each time frame level, with more moving averages becoming available as we move to shorter time frames.

Advanced Implementation Techniques

Error Prevention Strategy: The conditional logic prevents the common "secondary period cannot be less than primary" error that occurs when trying to access shorter time frame data from longer time frame charts. By using `Double.nan` for inaccessible moving averages, we ensure the indicator compiles without errors across all time frames.

Performance Optimization: Starting with the largest time frame and working down allows the code to exit early when conditions aren't met, improving execution speed. If the daily time frame isn't accessible, there's no need to check for hourly or shorter time frames.

Flexible Design: The input variables make this indicator adaptable to different trading styles. Day traders might prefer shorter periods, while swing traders could use longer periods for smoother signals.

Practical Trading Applications

Trend Confirmation Setups: Look for setups where price is above all four moving averages for strong bullish signals, or below all four for bearish signals. This alignment indicates trend agreement across multiple time frames.

Support and Resistance Levels: The daily moving average often acts as dynamic support in uptrends and resistance in downtrends. The hourly average provides intermediate-term levels, while the shorter time frame averages offer precise entry and exit points.

Pullback Trading: In strong trends, use the 30-minute and 15-minute moving averages to identify pullback completion. When price bounces off these shorter-term averages while remaining above the daily and hourly averages, it often signals trend continuation.

Divergence Analysis: Watch for situations where price makes new highs but the 15-minute average fails to exceed previous highs while the daily average continues upward. This can signal weakening momentum and potential reversal opportunities.

Customization and Enhancement Options

Color Coding Strategy: Assign distinct colors to each time frame's moving average to quickly identify them on the chart. Consider using cooler colors (blue, purple) for longer time frames and warmer colors (red, orange) for shorter time frames.

Moving Average Types: While our example uses SMAs and EMAs, you can substitute hull moving averages, weighted moving averages, or any other type based on your preferences. Different moving average types respond differently to price changes, offering various signal characteristics.

Additional Time Frames: Advanced traders might want to add weekly or monthly moving averages for even longer-term perspective, or incorporate additional intraday time frames like 5-minute or 1-minute for scalping strategies.

Alert Integration: Consider adding alert conditions for when price crosses specific moving averages or when moving averages cross each other, enabling automated notification of potential trading opportunities.

Common Implementation Challenges and Solutions

Aggregation Period Errors: The most common issue is trying to access shorter time frame data from longer time frame charts. Always use conditional logic to check the current time frame before accessing specific aggregation periods.

Chart Overcrowding: Four moving averages can create visual clutter. Use transparency settings or different line styles to maintain chart readability while preserving functionality.

Performance Issues: Multiple aggregation period calls can slow down chart performance, especially on slower computers. Optimize by minimizing unnecessary calculations and using efficient conditional logic.

Time Frame Synchronization: Be aware that some time frames might have slight data differences due to market hours or session definitions. Test your indicator across different symbols and time periods to ensure consistent behavior.

Testing and Validation

Before using any multi-time frame indicator in live trading, thoroughly test its behavior across different time frames and market conditions. Start with a 5-minute chart and progressively increase to 15-minute, 30-minute, hourly, and daily charts, verifying that the appropriate moving averages appear and disappear as expected.

Compare the values displayed by your indicator with manually plotted moving averages on separate time frame charts to ensure accuracy. Pay special attention to the transition points where certain moving averages should become available or unavailable based on the current time frame.

Test the indicator during different market sessions and on various symbol types (stocks, ETFs, forex, futures) to ensure consistent performance across your trading universe.

Best Practices for Multi-Time Frame Analysis

Maintain Time Frame Hierarchy: Always respect the longer time frame trend when making shorter time frame decisions. Don't fight the daily trend based on 15-minute signals alone.

Use Confluence Wisely: The strongest signals occur when multiple time frame moving averages align with other technical factors like support/resistance levels, volume, and momentum indicators.

Avoid Over-Analysis: While having multiple time frame information is valuable, don't let it lead to analysis paralysis. Develop clear rules for when to act based on moving average relationships.

Regular Optimization: Periodically review and adjust the moving average periods based on changing market conditions and your evolving trading style. What works in trending markets might need adjustment in ranging conditions.

Integration with Trading Strategies

Multi-time frame moving averages work exceptionally well when integrated with broader trading strategies. Trend following strategies benefit from the clear trend hierarchy provided by multiple time frame averages. Mean reversion strategies can use the moving averages to identify overbought/oversold conditions relative to different time frame trends.

Breakout strategies gain additional confirmation when breakouts occur with multiple time frame moving average support. Similarly, support and resistance trading becomes more precise when these levels align with dynamic moving average levels from various time frames.

Conclusion: Maximizing Your Trading Efficiency

Multiple time frame moving averages represent a sophisticated approach to technical analysis that provides comprehensive trend information while maintaining chart simplicity. By understanding aggregation periods and implementing proper conditional logic, you can create powerful tools that enhance your trading decision-making process.

The key to success with this approach lies in understanding the relationship between different time frame trends and using that information to improve your entry, exit, and risk management decisions. Start with the basic four-moving-average setup provided in this tutorial, then customize and expand based on your specific trading needs and style.

Remember that technology should serve your trading strategy, not complicate it. Use multi-time frame moving averages as a foundation for clearer market analysis, but always combine them with sound risk management and consistent execution for long-term trading success.

Multi-Time Frame Moving Averages.ts
#TOS Indicators

#Home of the Volatility Box

#Indicator Name: Multiple Time Frame Moving Averages

#Full tutorial here: https://tosindicators.com/indicators/multiple-moving-averages

input dailySMALength = 10;


// ... 45 more lines ...

Unlock This Code

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

Create Free Account Login
To create multiple time frame moving averages in ThinkOrSwim, use the aggregation period parameter in your moving average functions. For example: SimpleMovingAvg(close(period = "Day"), 10) creates a 10-period daily SMA on any time frame chart. Use conditional logic with getAggregationPeriod() to prevent errors when accessing time frame data that's shorter than your current chart.
ThinkScript's aggregation period limitation states that you can only access data from time frames equal to or greater than your current chart time frame. For example, if you're viewing a 30-minute chart, you cannot access 15-minute or 5-minute data, but you can access hourly, daily, or weekly data. This is why conditional logic is essential for multi-time frame indicators.
Prevent aggregation period errors by using conditional logic with getAggregationPeriod() function. Check the current time frame before defining moving averages: if getAggregationPeriod() >= AggregationPeriod.Hour then { /* define hourly MA */ } else { /* set to Double.nan */ }. This ensures your indicator only attempts to access appropriate time frame data.
Common effective combinations include: Daily 10-period SMA for trend direction, 1-hour 50-period EMA for intermediate trend, 30-minute 30-period EMA for short-term trend, and 15-minute 20-period EMA for entry timing. Adjust these periods based on your trading style - day traders might prefer shorter periods while swing traders use longer ones.
Yes, you can add additional time frames like weekly, monthly, or shorter intraday periods. However, be mindful of chart clutter and performance. Each additional aggregation period calculation requires more processing power. Consider using different line styles or transparency settings to maintain chart readability with multiple moving averages.
Add color assignments to your plot statements using .SetDefaultColor(). For example: SMAOneDayChart.SetDefaultColor(Color.BLUE); or EMAOneHourChart.SetDefaultColor(Color.RED);. You can also set colors through the indicator properties after applying it to your chart. Use distinct colors for easy identification of each time frame.
Moving averages disappear when changing time frames due to ThinkScript's aggregation period limitations. When you switch to a time frame that cannot access certain periods (like viewing a 1-hour chart that can't access 15-minute data), those moving averages are set to Double.nan. This is normal behavior and prevents errors. The conditional logic ensures only appropriate time frame moving averages display based on your current chart period.
Multiple time frame moving averages improve trading by providing trend context across different time horizons. When all time frame moving averages align (all pointing up or down), it signals strong trend consensus. Divergences between short and long-term moving averages can indicate potential trend changes. This comprehensive view helps with better entry timing, trend confirmation, and risk management decisions.

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

Simple Breakout Tool

Simple Breakout Tool

Beginner • 14 minutes
Advanced Volume Zone Oscillator

Advanced Volume Zone Oscillator

Beginner-Friendly • 25 mins
Multi-Time Frame (MTF) Squeeze Indicator

Multi-Time Frame (MTF) Squeeze Indicator

Beginner • 21 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.