Skip to main content

Trend Squeeze Indicator for ThinkOrSwim (Free Download)

IndicatorFreeBeginner23 min video58 lines of codeNov 17, 2024Updated Oct 21, 2026

A free trend squeeze indicator for ThinkOrSwim: arrows when the 3 EMA crosses the 8 EMA on a pullback, in a stacked trend, during a squeeze.

Trend Squeeze on a ThinkOrSwim chart
On this page

Overview

In this tutorial I build a trend squeeze indicator for ThinkOrSwim from scratch. It looks for a healthy trend, where the 3, 8, 21 and 34-period EMAs and the 50 and 200-period SMAs are stacked in order, then waits for a pullback, a squeeze and a shift in momentum before it plots an arrow.

The goal is to find the best Squeeze setups in places where the trend is already healthy, then ride the momentum. It's a beginner-friendly build, and one input turns the squeeze filter off so you can also use it as a standalone trend indicator.

Key Takeaways

  • The Trend Squeeze indicator for ThinkOrSwim plots an arrow when 4 conditions line up on the same bar: stacked moving averages, a squeeze, a 3/8 EMA cross and a pullback to the 8 EMA.
  • A healthy bullish trend means the 3 EMA is above the 8 EMA, the 8 above the 21, the 21 above the 34, the 34 EMA above the 50 SMA and the 50 SMA above the 200 SMA. The bearish stack is the reverse.
  • The squeeze check reads the SqueezeAlert plot of ThinkOrSwim's built-in Squeeze study at its default settings. A value of 0 means a red dot, so the squeeze is on.
  • 2 inputs control it: showLines (default yes) shows or hides the 6 moving averages, and squeezeRequired (default yes) turns the squeeze filter off so it works as a standalone trend indicator.
  • The only results in the video come from a preview of the members-only Part 2 backtester, which layers on the triple squeeze and adds its own exits. On the S&P 500 daily chart over 5 years, its trend exit had 10 winners and 4 losers.

What the Trend Squeeze Indicator Looks For

The Trend Squeeze indicator is a ThinkOrSwim study that finds Squeeze setups in places where the trend is already healthy. I built it to find the best squeeze setups in a trend and then ride the momentum. The logic follows the steps I walk through on the S&P 500 daily screenshot at the start of the video:

  1. Find a healthy trend. Six moving averages, four EMAs and two SMAs, have to be stacked in order.
  2. Look for a pullback. Price dips back into the moving averages, and the 3 EMA slips under the 8 EMA.
  3. Wait for a squeeze. The indicator needs the Squeeze's red dot on the bar.
  4. Wait for momentum to shift. Instead of entering in the chop of the pullback, it waits for the 3 EMA to cross back over the 8 EMA. That's where the arrow plots, the trend squeeze entry.

The table lists what has to be true on the bar for each arrow. If you're new to the red and green dots, our Squeeze hub covers what the dots mean, so this page doesn't repeat it.

Check on the signal barBullish arrowBearish arrow
Trend3 EMA > 8 EMA > 21 EMA > 34 EMA > 50 SMA > 200 SMA3 EMA < 8 EMA < 21 EMA < 34 EMA < 50 SMA < 200 SMA
Squeeze (when squeezeRequired is yes)Red dot: SqueezeAlert equals 0Red dot: SqueezeAlert equals 0
Momentum shift3 EMA crosses above the 8 EMA3 EMA crosses below the 8 EMA
PullbackThe bar's low is below the 8 EMAThe bar's high is above the 8 EMA
What plotsCyan up arrowPink down arrow

The free indicator marks entries only. It plots no exit, target or stop, so where you get out is up to you.

The Healthy Trend: Six Moving Averages in a Chain

A healthy trend in the Trend Squeeze indicator is a chain of 6 moving averages: the 3, 8, 21 and 34-period exponential moving averages, then the 50 and 200-period simple moving averages. Each one has to sit above the next for a bullish trend, from the 3 EMA at the top down to the 200 SMA. For a bearish trend, each one sits below the next.

The fast EMAs at the top of the chain are the ones a pullback moves first. The 50 and 200 SMAs at the bottom move slowly and describe the longer trend.

Our free Stacked Moving Averages indicator uses a shorter version of the same stack, and its tutorial covers how EMAs and SMAs differ. The comparison below comes from the two downloads.

FeatureTrend SqueezeStacked Moving Averages
EMAs3, 8, 21, 348, 21, 34
SMAs50, 20050, 200
34 EMA compared with the 50 SMAYes, it's part of the chainNo, only 50 SMA vs 200 SMA
When the arrow plotsPullback, squeeze and 3/8 EMA cross inside the stackThe first bar the stack forms

How to Build the Trend Squeeze Indicator in ThinkOrSwim

Building the Trend Squeeze indicator takes one new study in the thinkScript editor. I built it on a daily chart and clicked Apply after each piece to test it as I went.

  1. Open a chart. I used the daily timeframe.
  2. Click the Studies icon at the top of the chart, then click Create.
  3. Delete the code that's already in the editor and give the study a name. I called mine TI_TrendSqueeze.
  4. Write the code in the order of the steps below, or paste the finished code from the Code tab on this page.
  5. Click OK, then Apply.

If you'd rather start from the download, our guide on how to import a study into ThinkOrSwim covers that route.

How the Code Works

The Trend Squeeze code has 6 parts: the moving averages, the trend checks, the lines, the momentum cross, the squeeze check and the signals. Each snippet below is copied from the download.

Step 1: Define the Moving Averages

The # sign starts a comment. I wrote the trend rule as a comment at the top, 3 EMA above 8 EMA above 21 EMA and so on, so the chain is in front of me while I code.

This step’s code is free with an account. Create one or sign in.

ExpAverage takes 2 parameters, the price and the length. I used the closing price for all six. SimpleMovingAvg takes the same 2 parameters for a simple moving average.

Every built-in function is listed in the reference panel on the right of the thinkScript editor. The moving averages are under Functions, then Technical Analysis, and the Math and Options sections hold others.

Step 2: The Trend Checks

This step’s code is free with an account. Create one or sign in.

Each and adds one link to the chain, so bullTrendCheck is true only when all 5 comparisons hold on the same bar.

For the bearish check, I copied the line and reversed every sign.

Step 3: Lines You Can Turn Off

I like to test as I go, so the next step plots the averages behind an input. An input is a setting you can change from the studies menu without touching the code.

This step’s code is free with an account. Create one or sign in.

double.nan is how thinkScript says "show nothing". With showLines set to no, all 6 lines disappear and the arrows stay.

The two simple moving averages get a dashed style, so you can tell them apart from the EMAs at a glance:

This step’s code is free with an account. Create one or sign in.

Step 4: The Momentum Cross

The momentum shift is the 3 EMA crossing the 8 EMA. That's the most aggressive cross I'm willing to use.

This step’s code is free with an account. Create one or sign in.

The [1] reads the previous bar. A bullish cross means the 3 EMA is above the 8 EMA now and was at or below it one bar ago, so the cross happened on this bar.

To test it, I put a yellow chart bubble on every bar where the cross was true and compared the bubbles with our Momentum Cross indicator, which marks the same 3/8 EMA cross with dots. They lined up, and I removed the test bubble.

Step 5: The Squeeze Check

The squeeze check calls ThinkOrSwim's built-in Squeeze study with its default parameters and reads one plot, SqueezeAlert. It returns 0 on a red dot and 1 on a green dot.

This step’s code is free with an account. Create one or sign in.

squeezeAlert flips that around, so it's 1 when there is a squeeze. squeezeCheck passes when the squeeze is required and present. When you set squeezeRequired to no, it passes on every bar and the squeeze stops filtering anything.

In the video, the first version didn't compile because I left out the if at the start of the squeezeAlert line. If you type the code yourself, check that each line reads if ... then ... else.

Step 6: The Signals

The two signal plots bring every condition together. The last condition, the bar's low below the 8 EMA, makes sure the bar is still somewhat inside the pullback region.

This step’s code is free with an account. Create one or sign in.

Each signal returns 1 when everything is true and double.nan otherwise.

I used double.nan instead of 0 because the signal plots as an arrow. A line weight of 3 makes the arrows a bit bigger and easier to see without being too fat.

Look at how the trend check and the cross work together. During a pullback, the 3 EMA dips under the 8 EMA and breaks the top link of the chain. The arrow plots on the bar where the 3 EMA crosses back above and the whole chain is in order again.

The Inputs and Default Colors

The Trend Squeeze indicator has 2 inputs and 8 plots. The table lists the defaults in the download. Change any color from the studies menu, or edit the setDefaultColor line.

Setting or plotDefaultWhat it does
showLinesyesShows the 6 moving averages. Set it to no to keep only the arrows.
squeezeRequiredyesRequires a red Squeeze dot on the signal bar. Set it to no for a standalone trend indicator.
3 EMAPink, solidThe fastest line, half of the momentum cross
8 EMACyan, solidThe other half of the cross and the pullback line
21 EMAMagenta, solidMiddle of the chain
34 EMAYellow, solidSlowest EMA
50 SMAYellow, short dashSame color as the 34 EMA, told apart by the dashes
200 SMAWhite, short dashThe bottom link of the chain
Bullish arrowCyan, weight 3Up arrow on a bullish signal
Bearish arrowPink, weight 3Down arrow on a bearish signal

Squeeze Mode vs Standalone Trend Mode

The squeezeRequired input switches the Trend Squeeze indicator between two modes. With the default of yes, it's a squeeze indicator for the times when a squeeze and a healthy trend overlap. With no, it's a standalone indicator for trend trading.

ModesqueezeRequiredWhat has to line upArrows in the video
Squeeze modeyesStack, pullback, 3/8 EMA cross and a red Squeeze dotFew arrows on the daily chart
Standalone trend modenoStack, pullback and 3/8 EMA crossFar more arrows

In standalone mode, the arrows mark stacked moving averages, a pullback into those averages, and momentum turning price away from them again. That's something most traders do manually, and the arrow gives you a visual cue for it.

What the Arrows Showed in the Video

The Trend Squeeze arrows in the video plotted on the daily chart I built the indicator on and on a 5-minute chart. Here's what they did:

  • Daily chart, squeeze required. There were few arrows. When they plotted, they were good for decent trades, and when one wasn't, you'd know fairly quickly that the squeeze was going against you.
  • 5-minute chart. The indicator found the bullish and bearish arrows from Friday's session.
  • Squeeze turned off. Far more arrows plotted, each one a pullback and momentum shift inside stacked moving averages.

It isn't a perfect signal by any measure. I do think it's a nice way to enter on almost any timeframe.

Part 2 for Members: Backtester and Scans

The Trend Squeeze has a members-only Part 2. It takes this code as a starting point, layers on the triple squeeze to find more setups, and turns it into a backtester, with scans to find setups forming today. The Trend Squeeze Pro indicator, backtester and scans are in the Squeeze Course downloads.

The video opens with a preview of that backtester on the S&P 500 daily chart over 5 years. Its rules differ from the free indicator's: it layers on the triple squeeze, and the exits I tested were added for that backtester. These are historical results of the Part 2 tool from the video, not a test of the free arrows and not a forecast, and 14 trades is a small sample.

Exit tested in the Part 2 backtesterChart and periodResult shown
Trend exit (added for this backtester, rides the trend as long as possible)S&P 500, daily, 5 years10 winners, 4 losers
Exit when the squeeze firesS&P 500, daily, 5 years1 more winner and 3 fewer losers than the trend exit

With the trend exit, each loser was contained and the average winner was much greater than the average loser. The free indicator has no backtester. To test Squeeze-based rules for free, our Squeeze backtester and Squeeze histogram backtester are strategies you can run on any chart.

How I Use the Trend Squeeze Arrows

A Trend Squeeze arrow marks a pullback entry inside a trend that's already in place. It doesn't tell you how far the move will go, and it doesn't manage the trade after the entry.

Before you take an arrow, decide where your stop goes and size the position so a stop-out costs a small, fixed share of your account. In the video, an arrow that didn't work showed it fairly quickly, and a stop you set in advance keeps that loss small.

To check the squeeze on several timeframes at once, add our free MTF Squeeze indicator next to it. To find squeezes across a watchlist or the whole market, our Squeeze dots scan does the searching.

Common Problems

Most Trend Squeeze problems come from chart history, the squeeze filter, or a typo in hand-typed code.

  • No arrows at all. The 200 SMA needs 200 bars before it has a value, and the trend checks fail without it. Load more history on the chart.
  • Very few arrows. In squeeze mode, all 4 conditions have to land on one bar. Set squeezeRequired to no to see the standalone trend arrows.
  • The chart is cluttered. Set showLines to no. The arrows still plot.
  • The code won't compile. Check every if ... then ... else line, especially squeezeAlert and the else if in squeezeCheck.
  • An arrow appears and disappears on the current bar. Every check uses the bar's prices, which keep changing until the bar closes, so an arrow on the live bar can come and go.

For other errors, our tutorial on how to fix bugs in thinkScript code walks through finding them.

Trend Squeeze on real charts

Drawn from real daily bars with the code on this page, through Oct 20, 2026. An arrow needs all four at once: the 3, 8, 21 and 34 EMAs and the 50 and 200 SMAs stacked in order, a squeeze, the 3 EMA crossing the 8, and a pullback through the 8 EMA. I picked the most recent bullish arrow on a well-known name that was higher 10 days later, and the most recent that was not.

XOM, Sep 30, 2026: an arrow that followed through

Trend Squeeze arrow on a XOM daily chart in ThinkOrSwim, Sep 30, 2026: stacked averages, a squeeze and a 3/8 EMA cross on a pullback
XOM on Sep 30, 2026: the cyan arrow under the bar, with all six averages stacked and the squeeze on.

XOM closed at $162.87 on the arrow and at $177.04 ten trading days later, +8.7%.

JPM, Sep 3, 2026: one that did not

Trend Squeeze arrow on a JPM daily chart in ThinkOrSwim, Sep 3, 2026, that did not follow through
JPM on Sep 3, 2026: the same four conditions.

JPM closed at $362.14 on the arrow and at $349.67 ten trading days later, -3.4%. The stack says the trend was healthy going in; it cannot promise the next two weeks.

By the numbers

1,148Bullish arrows
718Bearish arrows
49.6%Bullish arrows higher 10 days later (since April 2025)
53.3%Any day higher 10 days later

Daily bars for 545 symbols with an arrow, Aug 29, 2016 to Oct 20, 2026: the 14 ETFs from 2016, most stocks from April 2025 (the 200 SMA needs 200 days). The two percentages compare the 980 bullish arrows since April 2025 with every day in the same stocks over the same months.

Full thinkScript code

Trend Squeeze.tsthinkScript · 58 lines
The full code is free with an account

Create a free account or sign in to copy all 58 lines and download the file.

Download

Trend Squeeze Indicator

Download the Trend Squeeze indicator for ThinkOrSwim. The download is a .zip with one study file, TI_TrendSqueezeSTUDY.ts, the same code as the Code tab on this page. It plots the 6 moving averages and the bullish and bearish arrows, with the showLines and squeezeRequired inputs. If you haven't added a custom study before, here's how to import an indicator into your ThinkOrSwim platform.

Download free

Video: Trend Squeeze, built line by line

23 minutes on YouTube.

Watch on YouTube

Questions

What is the Trend Squeeze indicator?

It's a free ThinkOrSwim study that plots an arrow when a squeeze and a healthy trend line up. The 3, 8, 21 and 34 EMAs and the 50 and 200 SMAs must be stacked in order, the bar must pull back to the 8 EMA, the Squeeze must show a red dot, and the 3 EMA must cross the 8 EMA.

How do I add the Trend Squeeze indicator to ThinkOrSwim?

Click the Studies icon, click Create, delete the starter code, name the study, and paste in the code from the Code tab. Click OK, then Apply. You can also download the .ts file and import it. The chart needs at least 200 bars so the 200 SMA has a value.

What moving averages define a healthy trend in the Trend Squeeze?

Six of them, stacked like a chain. For a bullish trend, the 3 EMA is above the 8 EMA, the 8 is above the 21, the 21 is above the 34, the 34 EMA is above the 50 SMA and the 50 SMA is above the 200 SMA. A bearish trend reverses every comparison.

What does the squeezeRequired input do?

It decides whether the arrow needs a squeeze. At the default of yes, an arrow plots only on a bar with a red Squeeze dot. Set it to no and the squeeze check passes on every bar, so the indicator works as a standalone trend indicator. In the video, that produced far more arrows.

Why does the Trend Squeeze check the 8 EMA on the signal bar?

It makes sure the bar is still inside the pullback. A bullish arrow needs the bar's low below the 8 EMA, and a bearish arrow needs the bar's high above it. That keeps the arrows on pullbacks into the moving averages instead of bars that are already stretched away from them.

Can I use the Trend Squeeze indicator on intraday charts?

Yes. The code doesn't depend on the timeframe. I built it on a daily chart and showed it on a 5-minute chart in the video, where it marked bullish and bearish arrows during Friday's session. On any timeframe, the chart needs 200 bars of history for the 200 SMA.

How does the indicator know when there's a squeeze?

It calls ThinkOrSwim's built-in Squeeze study with its default settings and reads the SqueezeAlert plot. That plot is 0 on a red dot, when the squeeze is on, and 1 on a green dot. The indicator treats a 0 as a squeeze.

What results did the Trend Squeeze backtester show in the video?

The only results come from a preview of the members-only Part 2 backtester, which layers on the triple squeeze and adds its own exits. On the S&P 500 daily chart over 5 years, its trend exit had 10 winners and 4 losers, and exiting when the squeeze fired gave 1 more winner and 3 fewer losers. The free indicator has no backtester.

Goes with

Get each new indicator by email

One email on Sundays with the week's new tool and its code. A free account also unlocks every .txt download.

No credit card. Unsubscribe anytime.