Skip to main content Earnings Day Trading Indicator 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
Intermediate 46 mins

Smarter Earnings

Analyze what price tends to do on the day of earnings, and find the best strategy to take advantage and profit from an earnings report.

Download Indicator
How to install in ThinkOrSwim →
Table of Contents
  • Understanding the Smarter Earnings Indicator
  • Setting Up Your ThinkOrSwim Workspace
  • Step 1: User Inputs
  • Step 2: Defining Global Variables
  • Step 3: Calculating Earnings Beats and Misses
  • Step 4: Identifying Gap Fills
  • Step 5: Calculating Gap N' Go Scenarios
  • Step 6: Calculating Expected Moves
  • Step 7: Adding Labels and Bubbles
  • Conclusion

Build a Smarter Earnings Trading System for Day-of-Earnings Analysis

Discover how to create the comprehensive Smarter Earnings indicator that transforms earnings trading from guesswork into systematic analysis using historical patterns and statistical data.

This advanced tutorial teaches you to build a complete earnings analysis system featuring:

  • Gap fill detection and analysis with beat/miss correlation
  • Gap-and-go pattern identification with average move calculations
  • Historical earnings beat/miss tracking and statistics
  • Expected move calculations vs. actual move analysis
  • Pre-market and after-market earnings classification
  • Visual chart bubbles for pattern identification
  • Comprehensive labeling system for quick analysis
  • Modular code design for future strategy additions

Perfect for traders who want to eliminate guesswork from earnings trading by creating systematic “if-this-then-that” plans based on historical data. This indicator focuses specifically on day-of-earnings analysis, not pre-earnings speculation.

Understanding the Smarter Earnings Indicator

Earnings season brings a wealth of information about companies’ financial health, and traders often look for patterns or anomalies surrounding these announcements. The Smarter Earnings Indicator aims to answer questions like:

  • Did a stock beat or miss its earnings estimates?
  • Did the price gap up or down following earnings, and if so, did it fill?
  • Did the price move beyond its expected range?

By integrating these elements, you get a robust view of how a stock typically responds during earnings announcements, making it easier to make informed trading decisions.

 

Setting Up Your ThinkOrSwim Workspace

Before we start scripting, ensure that you’re in the ThinkOrSwim platform. Navigate to Charts > Studies > Edit Studies and select Create to open the thinkScript editor. This is where we’ll enter our code.

Step 1: User Inputs

Let’s begin by setting up the inputs for our indicator. These inputs will allow users to customize which elements they want to see on the chart. For example, they may want to display gap fill labels, gap-and-go labels, or expected move labels based on their specific needs.

  
input expectedMoveLabels = yes;
input gapFillLabels = yes;
input gapNGoLabels = yes;
  
  

These three inputs enable users to toggle various labels on and off. Setting them to yes by default makes them visible unless the user decides to hide them.

Step 2: Defining Global Variables

Global variables form the foundation of our calculations. Here, we identify the earnings day and the timing of earnings (before or after the market). These variables will help us group data and later calculate gaps, fills, and trends.

  
def earningsDay = HasEarnings();
def beforeMarketEarnings = HasEarnings(EarningTime.BEFORE_MARKET);
def afterMarketEarnings = HasEarnings(EarningTime.AFTER_MARKET);
def groupBME = earningsDay and beforeMarketEarnings;
def groupAME = earningsDay[1] and afterMarketEarnings[1];
def earningsGroup = groupBME or groupAME;
def totalEarnings = TotalSum(earningsDay);
  
  

In this block, earningsDay is set to detect whether an earnings report is scheduled. We differentiate between earnings reported before the market opens (beforeMarketEarnings) and those reported after it closes (afterMarketEarnings). We then define groups based on these criteria to create an overarching earningsGroup variable.

Step 3: Calculating Earnings Beats and Misses

To determine whether earnings beat or missed expectations, we’ll compare estimated and actual earnings:

  
def EstimatedEarnings = if IsNan(getEstimatedEarnings()) then EstimatedEarnings[1] else getEstimatedEarnings();
def ActualEarnings = if IsNan(getActualEarnings()) then ActualEarnings[1] else getActualEarnings();
def earningsBeat = if (earningsGroup) and ActualEarnings > EstimatedEarnings then 1 else 0;
def earningsMiss = if (earningsGroup) and ActualEarnings < EstimatedEarnings then 1 else 0;
  
  

Here, we handle missing values with IsNan, which allows us to assign values based on previous data. The resulting earningsBeat and earningsMiss variables allow us to track whether the company met, exceeded, or missed expectations.

Step 4: Identifying Gap Fills

Next, we’ll determine whether price gapped up or down after earnings, and if so, whether it filled:

  
def gapUp = if earningsGroup and open > high[1] then 1 else 0;
def gapDown = if earningsGroup and open < low[1] then 1 else 0;
def gapUpFilled = if gapUp and low = low[1] then 1 else 0;
def gapUpFilledAndEarningsMiss = gapUpFilled and earningsMiss;
def gapDownFilledAndEarningsBeat = gapDownFilled and earningsBeat;
def totalGapUpFills = TotalSum(gapUpFilled);
def totalGapDownFills = TotalSum(gapDownFilled);
def totalGapFills = totalGapUpFills + totalGapDownFills;
def gapUpDidNotFill = (gapUp and !gapUpFilled);
def gapDownDidNotFill = (gapDown and !gapDownFilled);
def gapDidNotFill = gapUpDidNotFill or gapDownDidNotFill;
  
  

This code identifies upward and downward gaps and checks whether they filled. The variable gapUpFilled evaluates to 1 if a gap up filled, while gapUpDidNotFill returns 1 if it didn’t. These elements allow you to track trends and movement patterns post-earnings.

Step 5: Calculating Gap N' Go Scenarios

Sometimes, after gapping, prices continue in the direction of the gap without filling it. This is often called a “Gap N' Go.” The code below identifies bullish and bearish Gap N' Go scenarios:

  
def gapNGoBullish = if gapUpDidNotFill then 1 else 0;
def gapNGoBearish = if gapDownDidNotFill then 1 else 0;
def totalSumGNG = TotalSum(GapNGoBullish) + TotalSum(GapNGoBearish);
def totalSumGNGBullish =  TotalSum(GapNGoBullish);
def totalSumGNGBearish =  TotalSum(GapNGoBearish);
  
  

These Gap N' Go variables track the total number of instances in which a gap did not fill and instead continued in its original direction. This pattern can indicate momentum-driven price action that traders might leverage.

Step 6: Calculating Expected Moves

The expected move calculation considers implied volatility to forecast potential price range movement. This enables traders to measure whether actual price movement exceeded expectations.

  
def expectedEarningsMove = if earningsgroup then  Sqrt(2) / Sqrt(365)  * (2*imp_volatility()[1]) * close[1] else Sqrt(2) / Sqrt(365)  * (2*imp_volatility()[1]) * close[1];
def actualEarningsMove = if earningsGroup then AbsValue(close[1]-open) else 0;
def greaterThanExpected = actualEarningsMove > expectedEarningsMove;
def totalGreaterThanExpected = TotalSum(greaterThanExpected);
def totalGreaterThanExpectedPct = totalGreaterThanExpected/totalEarnings * 100;
  
  

Using the square root of time formula, we estimate the price's potential movement based on implied volatility. We compare the actual move with the expected range, and if the actual movement exceeds the range, we mark it for reference.

Step 7: Adding Labels and Bubbles

Finally, we add labels and chart bubbles to display the calculated values on the chart. This provides a visual reference to the data generated by the indicator.

  
AddLabel(gapFillLabels or gapNGoLabels or expectedMoveLabels, "Total # of Earnings: "+totalEarnings, color.white);
AddLabel(gapFillLabels, "Total Gap Fills: "+totalGapFills, color.cyan);
AddLabel(gapNGoLabels, "Total Gap N' Go's: "+totalSumGNG, color.green);
AddLabel(expectedMoveLabels, "# of Actual Greater Than Expected: "+totalGreaterThanExpected, color.yellow);
AddLabel(expectedMoveLabels, "% of Actual Greater Than Expected: "+totalGreaterThanExpectedPct, color.yellow);
AddChartBubble(earningsDay, low, "Earnings", Color.DARK_GREEN, no);
  
  

Each label and bubble displays a specific piece of information. You can toggle their visibility based on the inputs defined earlier.

Conclusion

With the Smarter Earnings Indicator, you gain insights into a stock's behavior around earnings announcements. The indicator helps you track earnings beats/misses, identify gaps and fills, and analyze the price action relative to expected moves. By adapting the inputs and settings, you can customize it for your trading style and strategy, whether you want detailed statistics or high-level information.

Smarter Earnings Indicator.ts
## Built by TOS Indicators 2019

## Smarter Earnings

## Last Update: 10/17/2019

## Full Tutorial Available Here: https://www.tosindicators.com/indicators/smarter-earnings

### User Inputs


// ... 167 more lines ...

Unlock This Code

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

Create Free Account Login
The Smarter Earnings indicator analyzes historical patterns on the actual day of earnings to create systematic trading plans. Instead of guessing direction, it provides statistical data on gap fills, gap-and-go moves, beat/miss correlations, and average moves. This allows you to create "if-this-then-that" plans based on what historically happens when specific conditions occur.
Gap fills occur when a stock gaps in one direction but then reverses to "fill" the gap by reaching the previous day's high/low - these are mean reversion plays. Gap-and-go patterns happen when stocks gap and continue trending in the same direction - these are momentum continuation plays. The indicator tracks both patterns with beat/miss correlations and average move statistics.
The expected move uses the formula: Sqrt(2) / Sqrt(365) * (2 * Implied Volatility) * Stock Price. This calculates what the options market expects for earnings day movement based on implied volatility. The indicator then tracks what percentage of time actual moves exceed these expectations, helping identify stocks that consistently surprise on volatility.
Yes, the indicator includes three user input controls: expectedMoveLabels, gapFillLabels, and gapNGoLabels. You can enable/disable each section based on your trading focus. For example, if you only trade momentum patterns, you can disable gap fill labels and focus solely on gap-and-go analysis to reduce chart clutter.
The indicator uses HasEarnings(EarningTime.BEFORE_MARKET) and HasEarnings(EarningTime.AFTER_MARKET) functions to classify earnings timing. For before-market earnings, it analyzes the same day's price action. For after-market earnings, it analyzes the following day's action using earningsDay[1] logic to ensure accurate pattern tracking.
Chart bubbles use distinct colors for easy pattern identification: Cyan bubbles mark gap fill events (with text indicating beat/miss correlation), Yellow bubbles identify gap-and-go patterns (bullish vs bearish), and Lime bubbles highlight when actual moves exceeded expected moves based on implied volatility. This visual system makes it easy to review historical patterns at a glance.
Use the indicator to create "if-this-then-that" scenarios before earnings announcements. Analyze historical patterns (gap fills vs gap-and-go, beat/miss correlations, average moves) to prepare systematic plans. For example: "If XYZ beats and gaps up, enter long targeting $2.50 average move with gap-fill stop." This eliminates emotional decision-making during volatile earnings periods.
Yes, the indicator uses modular code design specifically to allow easy expansion. The Global Variables, Gap Fill, and Gap-and-Go modules are self-contained, making it simple to add new strategies like pre-earnings analysis or multi-day post-earnings tracking without affecting existing functionality. The input controls also allow for selective display of different strategy components.

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

Adv. Covered Call Calculator

Adv. Covered Call Calculator

Beginner • 10 minutes
VScore

VScore

Beginner-Friendly • 28 mins
Supply Demand Edge

Supply Demand Edge

Beginner-Friendly • 20 mins

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.