# EARNINGS-FREE EQUITIES - Shows only equities that DO NOT have earnings in the next 45 days
#
# Scan tab study that selects only equities without earnings coming up in
# the next 45 days. To find stocks *with* earnings, see my other thinkScript:
# Today's Potential Earnings Plays: http://pastebin.com/gC1GJMfB
#
# By Chris Baker <[email protected]> @ChrisBaker97
# Latest version maintained at: http://pastebin.com/wZbyXgEZ
# More thinkScripts at: http://pastebin.com/u/ChrisBaker97
#
# This thinkScript is designed for use in the Scan tab. Detailed
# instructions may be found here: http://pastebin.com/wGi1Mvuh
#
# Future enhancement:
# • Incorporate extensive code from my optimal expiration cycle selection
# thinkScript (http://pastebin.com/SR7NDzLB) to dynamically adjust the
# horizon based on the actual expiration date of the option series closest
# to a user-defined optimal days to expiration.
#
# This work is licensed under the Creative Commons Attribution-ShareAlike
# 3.0 Unported License. To view a copy of this license, visit:
# http://creativecommons.org/licenses/by-sa/3.0/deed.en_US
#
# I created this because the default TOS Earnings filter only allows you
# to find stocks *with* earnings, but there's no way to reverse it to
# eliminate stocks *without* earnings, which is often desirable.
#
# If you want to tweak the time period, you may adjust the days input.
# For example, when set to 60, this will find all stocks without earnings
# announcements through the market open 60 days from now.
input days = 45;
declare once_per_bar;
plot scan = sum(HasEarnings(EarningTime.AFTER_MARKET),days)[1-days] +
sum(HasEarnings(EarningTime.BEFORE_MARKET),days)[0-days] < 1;