Welcome to the 13th episode of “How to thinkScript”.
In this video, we’re going to build a TTM Squeeze Dashboard for ThinkOrSwim, similar to what you often see people easily doing with TradeStation.
Here’s what our final dashboard will look like:
Table of Contents
- TTM Squeeze Dashboard Video Tutorial
- Stock Volatility Box Invite
- Designing the TTM Squeeze Dashboard
- How to Set Up a ThinkOrSwim Dashboard
- Stacked Moving Averages – thinkScript Code
- TTM Squeeze Dashboard – thinkScript Code
- Finding the Top 10 Holdings in each ETF
- Analyzing ETF Top Holdings With TTM Squeeze Dashboard
- Download Code (FREE)
The custom code written for the TTM Squeeze dashboard is available for free download below.
We are TOS Indicators.com, home of the Volatility Box. We started sending out invites for our new Stock Volatility Box Tool, which makes it dead easy to day trade stocks.
In the tutorial video, we show you an example of a trade in PHM.
PHM fell perfectly into our Volatility Box, and bounced from there. Our first target was 0.83% and the stock is currently up more than 2.2% from our entry point.
That’s the power of being able to use Volatility Models and Price Movement Ranges that you can trust.
Click here to sign up for our Stock Volatility Box Tool.
Before starting to build our TTM Squeeze Dashboard, we want to make sure we have a clear idea of how we’d like it to look. The final product, really.
Let’s make a quick mock using PowerPoint.
We’ll give this table 6 columns. You can customize them however you’d like, but for our tutorial, we’ll do this.
First column will be the symbol. Next, let’s say we want only the strongest candidates on this dashboard. So we want stacked moving averages.
Next we want to know where there are multiple squeezes. And we’ll design this with bigger time frames for swing trading, but if you want to day trade, make the time frames smaller.
So the columns we care about are:
- Stacked Moving Averages
- Daily Squeeze (large time frame)
- 1 Hour Squeeze (medium time frame)
- 30 Minute Squeeze (short time frame)
If you want to include other indicators, change the time frame, that’s all up to you, and easy to do.
Let’s get started.
For our TTM Squeeze Dashboard, we don’t really need to set up any PowerPoint slides here, so let’s just dive straight in.
We will open up our ThinkOrSwim platform, and rather than clicking the charts tab like we normally would, we will instead click the “MarketWatch” tab.
This is where we will be building the actual dashboard. However, we need to first start by creating a list of symbols. That needs to happen in our watchlist column.
Here, let’s start by creating a list of symbols. And the way we want to do this is like a funnel.
We want our largest ETF’s at the widest of this funnel. And we can keep narrowing down, based on top holdings, etc.
Here are the broad range ETF’s that we care about, which is similar to our Futures Volatility Box markets:
You get the idea. You can add as many, or as few symbols, as you would like in this first funnel for the dashboard.
Now let’s click either the top of the table, or the gear icon on the right hand side, and select “Customize” – this will be where we build our studies for each of these columns.
Quick side note – ThinkOrSwim limits the amount of total “quotes” as they call it, that you can have at any given moment. Your watchlist columns count as quotes, your custom studies in MarketWatch count as quotes, and even custom options chain quotes.
The more symbols you have, the more calculations ThinkOrSwim has to do, which are counted against your quotes allocation.
Back to our code…
The first column that we’ll tackle is the stacked moving averages. Here, we want to see if the 8 is above the 13 which is above the 21 which is above the 34. And vice versa. So this is incredibly narrow. But, it helps to keep us focused.
Now, let’s write the thinkScript code to define the exponential moving averages.
We’ll rename this to “Moving Averages” and make sure it’s set to a daily time frame. But you can change the time frame here if you would like.
def EMA8 = ExpAverage(close,8); def EMA13 = ExpAverage(close,13); def EMA21 = ExpAverage(close,21); def EMA34 = ExpAverage(close,34);
Now, we need to add a label.
Let’s do that:
def bullish = EMA8 > EMA13 and EMA13 > EMA21 and EMA21 > EMA34; def bearish = EMA8 < EMA13 and EMA13 < EMA21 and EMA21 < EMA34; AddLabel(bullish, “Stacked MAs”, color.black); AddLabel(bearish, “Stacked MAs”, color.black); AddLabel(!bullish and !bearish, " ", color.black); AssignbackgroundColor(if EMA8 > EMA13 and EMA13 > EMA21 and EMA21 > EMA34 then color.green else if EMA8 < EMA13 and EMA13 < EMA21 and EMA21 < EMA34 then color.red else double.nan);
Click OK and save the file.
Next, we want to define our columns for the squeeze. Now let’s introduce this idea of a 10-period lens.
Across the board, in each of our time frames, we would like to see what has been the sum of the red squeeze dots, across the past 10 bars.
- For the daily squeeze TTM_Squeeze, that means how many red dots over the past 10 days, using a daily squeeze
- For the 1hr squeeze TTM_Squeeze, that means how many red dots over the past 10 hours, using a hourly squeeze
- And for the 30 minute TTM_Squeeze, that means how many red squeeze dots over the past 5 hours, using a 30 minute squeeze.
Here’s some more thinkScript code to help us:
def squeeze = if TTM_Squeeze().SqueezeAlert == 0 then 1 else 0; def sumSqueeze= Sum(squeeze, 10); def squeezeFired = if TTM_Squeeze().SqueezeAlert == 0 and TTM_Squeeze().SqueezeAlert == 1 then 1 else 0;
Now, let’s go ahead and create similar labels here.
AddLabel(squeezeFired, “Sqz FIRED “, color.white); AddLabel(squeeze, “Sqz Count: “+sumSqueeze, color.white); AssignBackgroundColor(if squeezeFired then color.green else if squeeze then color.red else color.black);
In the above TTM squeeze dashboard code, we use the default parameters for the squeeze.
If you would like to tweak the settings, you can use our free TTM Squeeze Backtester to help you determine the best settings for your specific chart.
Let’s recap what we’ve been able to do so far:
- Determine if we have stacked moving averages, either bullish or bearish
- Determine if we have a daily squeeze, and if so, how many squeeze dots over the previous 10 bars
Now let’s copy paste this code 2 more times, for our remaining two time frames, and make sure we set the aggregation period accordingly.
We’ll copy paste the entire code once more:
def squeeze = if TTM_Squeeze().SqueezeAlert == 0 then 1 else 0; def sumSqueeze= Sum(squeeze, 10); def squeezeFired = if TTM_Squeeze().SqueezeAlert == 0 and TTM_Squeeze().SqueezeAlert == 1 then 1 else 0; AddLabel(squeezeFired, “Sqz FIRED “, color.white); AddLabel(squeeze, “Sqz Count: “+sumSqueeze, color.white); AssignBackgroundColor(if squeezeFired then color.green else if squeeze then color.red else color.black);
And that gives us our full dashboard.
Let’s complete the funnel now with a list of top holdings.
We’ll use ETFDb, a resource that will let us quickly find the Top ETF Holdings. You can change the ETF in the URL to easily navigate across top holdings:
Below is a list of 6 ETFs that we will break down in this dashboard, along with the Top Holdings from each respective ETF.
The list is separated by comma’s, so you can easily copy and paste the symbols into ThinkOrSwim.
Updated as of 1/29/20:
- ETF’s: XLF, XLY, XLV, XLP, XLE, XLU
- XLF: BRK.B, JPM, BAC, WFC, C, AXP, GS, USB, CME, TFC
- XLY: AMZN, HD, MCD, NKE, SBUX, LOW, BKNG, TJX, TGT, GM
- XLV: JNJ, UNH, MRK, PFE, MDT, ABT, BMY, AMGN, TMO, ABBV
- XLP: PG, KO, PEP, WMT, COST, MDLZ, MO, PM, CL, KMB
- XLE: XOM, CVX, EOG, COP, KMI, SLB, PSX, OXY, VLO, MPC
- XLU: NEE, SO, DUK, D, AEP, EXC, SRE, XEL, ED, WEC
Using the list above, let’s bring this video home, by going down the entire funnel.
Let’s start actually using this dashboard now. We’ll take a broad approach by starting with our list of ETFs.
Here is a snapshot of the TTM Squeeze Dashboard:
XLP is the only ETF with a current squeeze on either the daily, 1-hour or 30-minute time frame.
Let’s dig deeper… here is the dashboard for the Top 10 Holdings inside of XLP:
The only top holding with a squeeze is Walmart (WMT). Unfortunately, the moving averages signal a bearish move, versus the bullish moving averages for the broader ETF.
We can trim down the time frame to find more squeezes. Let’s change the aggregation period from daily, 1 hour, and 30 minutes to 15 minutes, 5 minutes and 3 minutes.
Here are the new results:
That’s more like it. Two results. Procter & Gamble (PG) and Coca Cola (KO).
Voila! It’s that simple to go from a broad ETF to exact opportunities, saving you time and letting ThinkOrSwim do the heavy lifting.
Click the button below to download the code to build your own TTM Squeeze Dashboard.