Trend Squeeze
Combine the TTM Squeeze with moving averages to find the best trend squeeze setups consistently
Introduction
The Trend Squeeze indicator is an advanced technical analysis tool that combines three powerful components to identify high-probability trading setups. B
y merging trend analysis, momentum, and volatility compression, the Trend Squeeze helps you pinpoint the exact time to enter a trade for a trend-trading setup.
The Trend Squeeze indicator combines the best of…
- Healthy trend detection – we’ll use stacked moving averages
- Momentum shifts – we’ll use the Momentum Cross
- TTM Squeezes – we’ll use the built-in TTM Squeeze
TTM Squeeze indicator for ThinkOrSwim
Together, the three in combination highlight key trading opportunities while filtering out noise — and they do it seamlessly.
In this step-by-step guide, I’ll walk you through coding the Trend Squeeze Indicator, explaining the logic behind every decision, and helping you master its use for better trading results.
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
What Is the Trend Squeeze Indicator?
The Trend Squeeze Indicator combines three key components:
- Healthy Trends: Identifies markets with strong directional movement using stacked moving averages.
- Momentum Crossovers: Tracks shifts in momentum using exponential moving averages (EMAs).
- TTM Squeeze: Detects low-volatility periods when big moves are most likely to occur.
These components work together to show you when the market is primed for significant movement and where to focus your attention.
The final Trend Squeeze indicator (after we’re done coding!) will allow you to:
- Filter out market noise by requiring multiple confirmations
- Identify high-probability setups where trend, momentum, and volatility align
- Reduce false signals through its multi-layered approach
- Work across multiple timeframes and markets
Let’s dive in!
Step 1: Define and Plot Moving Averages
We start by creating variables for moving averages, which are the foundation for identifying healthy trends. In this indicator, we’re using a mix of exponential moving averages (EMAs) and simple moving averages (SMAs).
Here’s what each moving average does:
- 3 EMA: Tracks short-term price momentum.
- 8 EMA: Slightly longer-term momentum, smoothing out noise compared to the 3 EMA.
- 21 EMA: Helps define intermediate-term price movement.
- 34 EMA: Adds another layer for medium-term trends.
- 50 SMA: A widely-used benchmark for medium-term trend analysis.
- 200 SMA: Tracks the long-term trend and is often seen as a key support/resistance level.
Here’s the code to define these moving averages:
def EMA3 = ExpAverage(close, 3);
def EMA8 = ExpAverage(close, 8);
def EMA21 = ExpAverage(close, 21);
def EMA34 = ExpAverage(close, 34);
def SMA50 = SimpleMovingAvg(close, 50);
def SMA200 = SimpleMovingAvg(close, 200);
Why Define Moving Averages This Way?
In ThinkOrSwim, ExpAverage
calculates an EMA, while SimpleMovingAvg
calculates an SMA. The close
parameter tells ThinkOrSwim to base the calculation on the closing price of each bar.
After defining these averages, we need to make them visible on the chart.
This is where the plot
function comes in:
plot EMA3Plot = if showLines then EMA3 else Double.NaN;
EMA3Plot.setDefaultColor(Color.Pink);
plot EMA8Plot = if showLines then EMA8 else Double.NaN;
EMA8Plot.setDefaultColor(Color.Cyan);
// Repeat for EMA21, EMA34, SMA50, and SMA200
Why Create Plot Variables?
When you define variables with def
, ThinkOrSwim calculates their values but doesn’t display them.
The plot
command makes the variable visible on your chart.
In the example from our tutorial:
showLines
is an input variable that lets you toggle the visibility of moving averages.Double.NaN
means “not a number,” which hides the plot whenshowLines
is set tono
.
Customizing the Look
We’ve customized the moving averages to make them visually distinct:
- Colors: Each moving average is assigned a unique color (e.g., pink for 3 EMA, cyan for 8 EMA).
- Styles: The 50 SMA and 200 SMA use dashed lines to differentiate them from the EMAs.
Step 2: Identify Healthy Trends
Now that your moving averages are plotted, let’s define what makes a trend “healthy.”
A healthy trend has stacked moving averages in the correct order.
Here’s the code:
def bullTrendCheck = EMA3 > EMA8 and EMA8 > EMA21 and EMA21 > EMA34 and EMA34 > SMA50 and SMA50 > SMA200;
def bearTrendCheck = EMA3 < EMA8 and EMA8 < EMA21 and EMA21 < EMA34 and EMA34 < SMA50 and SMA50 < SMA200;
These checks ensure the moving averages are aligned in a way that confirms strong trends:
- Bullish Trend: Shorter moving averages (e.g., 3 EMA) are above longer ones (e.g., 200 SMA).
- Bearish Trend: The opposite is true—shorter moving averages are below longer ones.
This filtering keeps you focused on trends with high directional strength, reducing false signals.
Step 3: Add Momentum Crossovers
Momentum crossovers help you time your entries. Specifically, we’re looking for the 3 EMA to cross above or below the 8 EMA, and this will serve as our “catalyst”:
def bullMomentumCross = EMA3 > EMA8 and EMA3[1] <= EMA8[1];
def bearMomentumCross = EMA3 < EMA8 and EMA3[1] >= EMA8[1];
How It Works
EMA3[1]
refers to the value of the 3 EMA from the previous bar.- If the current 3 EMA is above the 8 EMA, but the previous 3 EMA was below, a bullish crossover has occurred.
Why This Matters
These crossovers indicate when momentum is shifting in favor of the trend. This step prevents you from entering too early or chasing late moves.
Step 4: Add the TTM Squeeze
The TTM Squeeze is a key component of this indicator. It identifies periods of low volatility—prime conditions for breakouts. Here’s how to integrate it:
def squeezeAlert = if TTM_Squeeze().SqueezeAlert == 0 then 1 else 0;
input squeezeRequired = yes;
def squeezeCheck = if squeezeRequired and squeezeAlert then 1
else if !squeezeRequired then 1
else 0;
What This Code Does
SqueezeAlert
checks for the red dots on the TTM Squeeze indicator, which signify a squeeze.- The
squeezeCheck
variable lets you choose whether a squeeze is required for signals to be generated.
Why Use the TTM Squeeze?
Breakouts are often preceded by periods of consolidation. The TTM Squeeze helps you identify when these conditions exist, increasing the likelihood of catching significant moves.
Step 5: Combine All Conditions
Finally, you’ll bring everything together to plot buy and sell signals. Here’s the code:
plot bullSignal = if bullTrendCheck and squeezeCheck and bullMomentumCross and low < EMA8 then 1 else Double.NaN; bullSignal.setPaintingStrategy(PaintingStrategy.Boolean_Arrow_Up); bullSignal.setDefaultColor(Color.Cyan); bullSignal.setLineWeight(3); plot bearSignal = if bearTrendCheck and squeezeCheck and bearMomentumCross and high > EMA8 then 1 else Double.NaN;
bearSignal.setPaintingStrategy(PaintingStrategy.Boolean_Arrow_Down);
bearSignal.setDefaultColor(Color.Pink);
bearSignal.setLineWeight(3);
What This Code Does
bullSignal
: Plots an upward arrow when all bullish conditions are met.bearSignal
: Plots a downward arrow for bearish conditions.
Testing Your Indicator
Once the code is complete, test it on different timeframes and instruments. Look for how well it identifies trends, squeezes, and momentum shifts. Fine-tune the settings if needed to match your trading style.
Tips for Using the Trend Squeeze Indicator
- Combine with Other Tools: Use the indicator alongside support/resistance levels or trendlines for added confirmation.
- Adapt to Your Style: Experiment with different timeframes and settings to match your trading goals.
- Practice Discipline: Stick to the conditions you’ve coded and avoid overriding signals based on emotions or hunches.
Summary
You’ve now built a versatile and effective Trend Squeeze Indicator.
By focusing on healthy trends, momentum shifts, and low-volatility squeezes, this tool can help you identify high-probability setups and improve your trading discipline.
Download the code, test it, and start using it to take your trading strategy to the next level.
Happy trading!
downloads
Download the Trend Squeeze Indicator for ThinkorSwim.
The download contains a STUDY.ts file, which you can directly import into your ThinkOrSwim platform.
Download Indicator
Download the Trend Squeeze Indicator for ThinkorSwim.
The download contains a STUDY.ts file, which you can directly import into your ThinkOrSwim platform.