Skip to main content

Smarter Earnings Indicator for ThinkOrSwim (Free Download)

IndicatorFreeIntermediate46 min video108 lines of codeOct 7, 2019

Smarter Earnings is a free ThinkOrSwim indicator that counts gap fills and gap and go moves on past earnings days, split by beats and misses.

Smarter Earnings on a TTD chart in ThinkOrSwim
On this page

Overview

In this tutorial I build Smarter Earnings, a free ThinkOrSwim indicator for the day of earnings. It looks at every past report on your chart and asks what price did right after it: did the stock gap up or down, did the gap fill or did it gap and go, and did the company beat or miss its estimate?

The answers show up as labels at the top of the chart and as bubbles on each earnings bar, so you can see a stock's personality before its next report. I built it for traders who would rather wait for the number and trade the reaction than hold through the report. It's episode 9 of my How to thinkScript series.

Key Takeaways

  • Smarter Earnings is a free ThinkOrSwim indicator that studies the day of earnings only: whether price gapped, whether the gap filled, and whether the company beat or missed its estimate.
  • A gap up means the earnings bar opened above the previous bar's high, and a gap down means it opened below the previous bar's low. The gap fills when the same bar trades back to that level.
  • Beats and misses come from 2 built-in thinkScript functions, GetActualEarnings() and GetEstimatedEarnings(). Reports released after the close are measured on the next bar.
  • In the video, Roku's daily chart showed 8 earnings, 1 gap fill and 7 gap and go moves, 5 of them bullish, with an average bullish move of about $7.40.
  • The download adds a label group the video doesn't build: a rough expected move from implied volatility, compared with the actual gap on each earnings day.

What the Smarter Earnings Indicator Measures

The Smarter Earnings indicator measures what price did in the first session after each earnings report. It leaves the run-up into earnings to other tools and focuses on the reaction once the number is out.

I planned it as a tree diagram before writing any code: find the earnings bar, check for a gap up or a gap down, check whether the gap filled or kept going, and line that up with the earnings result. With no gap, the indicator does nothing for that report.

Common sense says each outcome should fit an earnings result, such as a gap up that fills on a miss. The table shows the 4 pairings the indicator tracks.

GapWhat price did on the earnings barResult that fitsName in the indicator
Gap upCame back down to fill the gapMissGap up fill
Gap upKept going without fillingBeatBullish gap and go
Gap downCame back up to fill the gapBeatGap down fill
Gap downKept going without fillingMissBearish gap and go

Counted across every report on the chart, these outcomes show whether a stock has a personality, such as gapping and going after beats. That history becomes a written plan before the next report.

Reading the Smarter Earnings Labels and Bubbles

The Smarter Earnings labels sit at the top of the chart in color groups, and each earnings bar gets a bubble so you can check every count against the price action. These are the labels in the download:

LabelColorWhat it shows
Total # of EarningsWhiteEarnings reports on the chart
Greater Than Expected Move X% of TimeLimeShare of reports where the actual gap was bigger than the rough expected move
Total Gap FillsCyanGap ups and gap downs that filled on the earnings bar
Total Gap Up Fills: X, Y on MissCyanGap up fills, and how many came on an earnings miss
Total Gap Down Fills: X, Y on BeatCyanGap down fills, and how many came on a beat
Total Gap N' GoYellowGaps that didn't fill
GNG Bullish: X, Y on BeatsYellowGap ups that didn't fill, and how many came on a beat
GNG Bearish: X, Y on MissesYellowGap downs that didn't fill, and how many came on a miss
GNG Avg Bullish Move and GNG Avg Bearish MoveYellowAverage dollar move from the open to the high (bullish) or to the low (bearish) on those bars
GNG Lowest Bullish Move and GNG Lowest Bearish MoveYellowThe smallest of those moves

The bubbles use the same colors. Cyan bubbles read Gap Up Filled or Gap Down Filled, with On Earnings Miss or On Earnings Beat added when the result matched. Yellow bubbles mark Gap N' Go Bullish and Gap N' Go Bearish. Lime bubbles show the expected move and the actual move on each earnings bar.

One more lime bubble appears on the latest bar when the next session is the one that will react to a report, showing the expected move ahead of time.

Inputs

InputDefaultWhat it turns on
gapFillLabelsyesThe cyan gap fill labels
gapNGoLabelsyesThe yellow gap and go labels
expectedMoveLabelsyesKeeps the white total and the lime expected move label on when the other 2 are off

The gap fill and gap and go inputs each switch one group, so you can hide a strategy that doesn't fit your trading and cut the noise on the chart. The white total and the lime expected move label show while any of the 3 inputs is on. The inputs control the labels only, and the bubbles always plot.

If you want to change the label text or colors, our AddLabel tutorial covers the syntax used at the bottom of the script.

How to Add Smarter Earnings to ThinkOrSwim

Smarter Earnings installs like any other custom study. You can import the .ts file from the download, or build it yourself: in the video I went to Charts, clicked the studies icon, clicked Create, and named the new study TI_SmarterEarnings.

  1. Download the zip and unzip TI_SmarterEarningsSTUDY.ts.
  2. Import the file as a study in ThinkOrSwim, or create a new study and paste in the code from the Code tab.
  3. Add it to a daily chart. The time range sets how many reports it counts: a 1-year chart shows 4 earnings, and a 2-year chart shows 8.
  4. Open the study settings to turn label groups on or off.

If you haven't added a custom study before, our guide on how to import a study into ThinkOrSwim walks through it.

How the Smarter Earnings Code Works

The Smarter Earnings code is built in modules: global variables, estimated versus actual earnings, gap fills, gap and go, and the labels and bubbles. I broke every condition into its own variable, even where two could be combined, so future versions can reference each piece.

Global Variables: Finding the Earnings Bar

HasEarnings() marks the bar of the report date, and its EarningTime parameter separates reports released before the open from those released after the close. Our upcoming earnings scan tutorial covers the function and that parameter in full, including how to scan for future report dates.

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

The key line is groupAME. An after-market report can't move price until the next session, so it reads the previous bar with [1]. earningsGroup combines both groups so later modules land on the reaction bar.

TotalSum(earningsDay) counts the reports on the chart. To test a variable as you build, I added a temporary bubble, not in the download: AddChartBubble(earningsGroup, close, earningsGroup, Color.YELLOW);. On AMD, which reports after market hours, the bubble landed on the next bar, as it should.

Estimated vs. Actual Earnings: Beat or Miss

GetEstimatedEarnings() and GetActualEarnings() are functions built into ThinkOrSwim that return the estimated and the reported earnings per share. Each line checks IsNaN first, and when a bar has no value, it carries the previous bar's value forward with [1].

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

A beat is actual above the estimate, and a miss is actual below it. An exact match counts as neither.

When I tested this on AMD in the video, one bar showed an estimate of 0.097 and an actual of 0.11, and another showed 7 cents estimated and 8 cents actual. Both were beats.

Gap Fills

A gap up needs the open above the previous bar's high. Most people would expect the previous close here, and I chose the high on purpose so the indicator counts exaggerated gaps whenever possible. A gap down needs the open below the previous bar's low.

The fill check runs on the same bar. A gap up fills when that bar's low trades back down to the previous high, and a gap down fills when its high trades back up to the previous low. An open above the previous close but below the previous high doesn't count as a gap.

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

Later lines pair each fill with the earnings result and total them with TotalSum.

The pairs have names such as gapUpFilledAndEarningsMiss. A gap that doesn't fill is stored as gapUpDidNotFill or gapDownDidNotFill, using ! to mean not.

Gap and Go

A gap and go is a gap that never filled on the earnings bar: price kept going in the direction it gapped. In the download, every unfilled gap counts as a gap and go, and the WithEarnings versions count the ones that came with the matching result.

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

A beat matches a bullish gap and go, and a miss matches a bearish one. Those feed the on Beats and on Misses counts in the labels.

The average move is measured on the same bar: the high minus the open for a bullish gap and go, and the open minus the low for a bearish one. I measure from the open because that's the first price you can act on once you know the result and the gap.

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

I calculated the average by hand. TotalSum adds up the moves, a second TotalSum of the 1s works as a counter, and the sum divided by the counter gives the average across the whole chart. LowestAll finds the smallest move.

Expected Move (Added in the Download)

The expected move module is in the download, and I don't build it in the video. The code comment calls it a rough calculation that uses a 2-day square root: the previous bar's implied volatility, doubled, times the square root of 2 divided by the square root of 365, times the previous close.

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

The actual move is the gap from the previous close to the earnings bar's open. A gap bigger than the expected move counts toward the Greater Than Expected Move percentage.

Both branches of the if statement use the same formula, so the expected move exists on every bar. That lets the last-bar bubble show it ahead of the next report.

Video Build vs. Download

The Smarter Earnings download (its header says last updated 10/17/2019) goes further than the version I build in the video. The Code tab on this page is the download file. These are the differences:

PartBuilt in the videoIn the download
InputsgapFillLabels and gapNGoLabelsAdds expectedMoveLabels
Gap and goCounts an unfilled gap only with the matching result: a beat for bullish, a miss for bearishCounts every unfilled gap, and shows how many came with the matching result
Expected moveNot builtRough expected move from implied volatility, a percentage label and lime bubbles
Lowest moveNot builtGNG Lowest Bullish Move and GNG Lowest Bearish Move labels

Roku appears twice in the video with different gap and go counts. The indicator I showed at the start counted 7 gap and go moves, 5 of them bullish. The version I built on camera, which needs the matching result, counted 5, with 4 bullish. The video doesn't say why.

Examples from the Video: Roku, AMD, Microsoft and The Trade Desk

The Smarter Earnings examples in the video are historical counts from daily charts in 2019, and each covers only the reports on that chart. Today's charts will show different numbers.

StockEarnings on the chartGap fillsGap and goAverage move
Roku (ROKU), at the start of the video8, about 2 years1, a gap up that filled7, with 5 bullishAbout $7.40 on bullish gap and go
AMD121, a gap up that filled on a miss7: 4 bullish, 3 bearish84 cents bullish, $1.14 bearish
Microsoft (MSFT)12, a 3-year chart4: 3 gap ups and 1 gap down5, all bullishAbout 79 cents bullish
The Trade Desk (TTD)124: 3 gap ups and 1 gap down5, all bullish$12.02 from the open, bullish

AMD, Microsoft and The Trade Desk come from the version I built in the video, where a gap and go needs the matching result. Microsoft's 5 gap and go moves all came with beats and traveled about 79 cents on average over the 3 years.

None of The Trade Desk's gap up fills came on a miss, and its one gap down fill came on a beat. That report came out after the close, the next bar gapped down and filled, and the numbers were 53 cents estimated against 65 cents actual.

I pointed out one false signal on Roku while recording. The code has a few glitches, which is why every count has a bubble you can check on the chart.

How I Use Smarter Earnings: An If-This-Then-That Plan

Smarter Earnings is a planning tool for the session after a report. Here is the process I describe in the video:

  1. Find stocks with earnings in the next day or two. Our free upcoming earnings scan builds that list.
  2. Add Smarter Earnings to each chart and read the labels.
  3. Write the plan before the report. My example for Roku: if it gaps up and the report is a beat, expect a gap and go and look for a reason to get in on the long side.
  4. When the report comes out, confirm the gap and the result, then follow the plan with a trade that suits your account size and risk tolerance.

This way you skip the overnight earnings risk and trade the reaction once the information is out, using what happened the last times the same thing occurred. The history is a lean, and the next report can break the pattern. Before entering, decide where your stop goes and size the position so a stop-out costs a small, fixed share of your account.

Our upcoming earnings with high short interest scan uses Smarter Earnings as one of its checks. For the days before a report, Volatility Box members have the Pre-Earnings Analysis indicator.

Our research article How to Trade the Day of Earnings with the Smarter Earnings Indicator is another place to start. The earnings page collects the rest of our earnings tools, and more free studies are on the indicators page.

Full thinkScript code

Smarter Earnings.tsthinkScript · 108 lines
The full code is free with an account

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

Download

Smarter Earnings Indicator

Download the Smarter Earnings indicator for ThinkOrSwim. The download is a .zip with one file, TI_SmarterEarningsSTUDY.ts, the same code as the Code tab on this page (last updated 10/17/2019). It includes the expected move labels, which the video doesn't build. Import the .ts file as a study. If you haven't added a custom study before, here's how to import an indicator into your ThinkOrSwim platform.

Download free

Video: Smarter Earnings, built line by line

46 minutes on YouTube.

Watch on YouTube

Questions

What does the Smarter Earnings indicator do?

Smarter Earnings is a free ThinkOrSwim study that looks at each earnings day on your chart and counts what price did: gap fills, gap and go moves, and whether each came with an earnings beat or miss. Labels at the top show the totals and the average moves, and chart bubbles mark every case.

How does Smarter Earnings define a gap up?

A gap up is an earnings bar that opens above the previous bar's high. Most people would expect the previous close, and I chose the high on purpose so the indicator counts exaggerated gaps. A gap down opens below the previous bar's low. The gap fills if the same bar trades back to that level.

What is a gap and go in the Smarter Earnings indicator?

A gap and go is an earnings gap that doesn't fill: price keeps moving in the direction it gapped. A bullish gap and go is an unfilled gap up, and a bearish one is an unfilled gap down. The labels also show how many came with a beat or a miss, and the average and lowest move from the open.

How does the indicator know if earnings beat or missed?

It compares two built-in thinkScript functions on the earnings bar, GetActualEarnings() and GetEstimatedEarnings(). Actual above the estimate is a beat, and actual below it is a miss. In the video, an AMD report with a 0.097 estimate and a 0.11 actual counted as a beat.

Why does the Smarter Earnings bubble show up the day after earnings?

The report came out after the market closed, so price couldn't react until the next session. The code checks HasEarnings(EarningTime.AFTER_MARKET) on the previous bar and measures the gap on the current one. Reports released before the market opens are measured on the same day.

How do I add Smarter Earnings to ThinkOrSwim?

Download the zip, unzip TI_SmarterEarningsSTUDY.ts, and import it as a study in ThinkOrSwim. Or create a new study and paste in the code from the Code tab. Add it to a daily chart: a 1-year chart covers 4 earnings, and a 2-year chart covers 8.

How does Smarter Earnings calculate the expected move?

The download uses a rough formula: the square root of 2 divided by the square root of 365, times twice the previous bar's implied volatility, times the previous close. It compares that with the actual gap from the previous close to the open and shows how often the gap was bigger. The video doesn't build this part.

What chart should I use with Smarter Earnings?

Use a daily chart. The indicator counts every report in view, so the time range sets the sample: a 1-year chart shows 4 earnings, a 2-year chart 8, and the 3-year Microsoft chart in the video showed 12. A longer chart gives a longer average, such as a 5-year average on a 5-year chart.

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.