Days Until Earnings Watchlist for ThinkorSwim

tomsk

Well-known member
VIP
Here is a Days to Earnings Watchlist that I have been using for years.
Hope this helps someone

Code:
# TDE - Trading days til earnings
# Displays the trading days til earnings. after-market earnings add 0.5 to the count.
# This code is meant to be pasted into a custom watchlist column
#
# Author: Allen Everhart
# Date: Oct 8, 2013
# Rev 1.3: Oct 19, 2014 code code watchlist column
# Rev 1.2: Mar 8, 2014 color code the after-market earnings.
# Rev 1.1: Oct 22, 2013 add 0.5 if earnings are after-market.

input length=60;
def xx = -getEventOffset(Events.EARNINGS);
def yy = sum(HasEarnings(type = EarningTime.AFTER_MARKET),length)[-length +1] > 0;
plot x=xx+yy*.5;
AssignBackgroundColor( if x < 8 then Color.RED else Color.BLUE);
 

tomsk

Well-known member
VIP
@markos I have tested probably well over a dozen different such watchlists. That one I posted is the one I use and is the best in my opinion. Glad you have it too
 

mc01439

Well-known member
2019 Donor
VIP
Here is the one I use, it has proven to be very good.

OOaP8uK.png


Code:
# +--------------------------------------------------+


# |          Highlight days around earnings          |
# |                   Robert Payne                   |
# |           http://rrpayne.blogspot.com            |
# +--------------------------------------------------+
input daysBefore = 10;
input daysAfter = 10;

input showLines = yes;
input paintBackground = yes;

DefineGlobalColor("Before Earnings", Color.YELLOW);
DefineGlobalColor("Earnings Release Date", Color.YELLOW);
DefineGlobalColor("After Earnings", Color.CYAN);
DefineGlobalColor("Fill Before", CreateColor(178, 216, 166));
DefineGlobalColor("Fill After", CreateColor(131, 191, 213));

AddVerticalLine(showLines and HasEarnings()[-daysBefore], Concat(daysBefore, " Days Before" ), GlobalColor("Before Earnings" ), Curve.FIRM);
AddVerticalLine(showLines and HasEarnings(), "Earnings!", GlobalColor("Earnings Release Date" ), Curve.FIRM);
AddVerticalLine(showLines and HasEarnings()[daysAfter], Concat(daysAfter, " Days After" ), GlobalColor("After Earnings" ), Curve.FIRM);

def before = Sum(HasEarnings(), daysBefore)[-daysBefore];
def after = Sum(HasEarnings(), daysAfter)[1];

def value1 = Double.Positive_Infinity;
def value2 = if paintBackground and before then Double.Negative_Infinity else Double.NaN;
def value3 = if paintBackground and after  then Double.Negative_Infinity else Double.NaN;

AddCloud(value1, value2, GlobalColor("Fill Before" ));
AddCloud(value1, value3, GlobalColor("Fill After" ));
 

apollo23

New member
Here is a Days to Earnings Watchlist that I have been using for years.
Hope this helps someone

Code:
# TDE - Trading days til earnings
# Displays the trading days til earnings. after-market earnings add 0.5 to the count.
# This code is meant to be pasted into a custom watchlist column
#
# Author: Allen Everhart
# Date: Oct 8, 2013
# Rev 1.3: Oct 19, 2014 code code watchlist column
# Rev 1.2: Mar 8, 2014 color code the after-market earnings.
# Rev 1.1: Oct 22, 2013 add 0.5 if earnings are after-market.

input length=60;
def xx = -getEventOffset(Events.EARNINGS);
def yy = sum(HasEarnings(type = EarningTime.AFTER_MARKET),length)[-length +1] > 0;
plot x=xx+yy*.5;
AssignBackgroundColor( if x < 8 then Color.RED else Color.BLUE);
Anybody know how to modify this script so that we can sort the earning release date? So that we can know how many days is the earning is coming up. Thanks
 

Fufi007

New member
This is a suggestion to get around the sort problem until one is provided or found. On your Scan window, select 'Export to Excel' off the menu. Then, open an Excel worksheet and paste the data off the clipboard. Add titles and filters to the Excel columns. You can sort any pasted column using any of the added filters. The problem sorting the watchlist's earnings column is date is shown as MM/DD/YY, contains numbers of days just before the date. The format for sorting should be YYYY/MM/DD followed by number of days. The study should be enhanced to provide the capability of selecting either one of the formats (MM/DD/YYYYY or YYYY/MM/DD). Hope this helps...
 
Last edited:

markos

Well-known member
VIP
This is a suggestion to get around the sort problem until one is provided or found. On your Scan window, select 'Export to Excel' off the menu. Then, open an Excel worksheet and paste the data off the clipboard. Add titles and filters to the Excel columns. You can sort any pasted column using any of the added filters. The problem sorting the watchlist's earnings column is date is shown as MM/DD/YY, contains numbers of days just before the date. The format for sorting should be YYYY/MM/DD followed by number of days. The study should be enhanced to provide the capability of selecting either one of the formats (MM/DD/YYYYY or YYYY/MM/DD). Hope this helps...
I have absolutely no problem sorting for earnings using the study in post #1. Do you really need the date? I just want to know if its coming up. 5 means 5 trading days away. Don't make it more dificult than that. BTW, there may be one written in the One Note located in Tutorials. It's updated every day.
 

miklosh13

New member
VIP
Here is the one I use, it has proven to be very good.

OOaP8uK.png


Code:
# +--------------------------------------------------+


# |          Highlight days around earnings          |
# |                   Robert Payne                   |
# |           http://rrpayne.blogspot.com            |
# +--------------------------------------------------+
input daysBefore = 10;
input daysAfter = 10;

input showLines = yes;
input paintBackground = yes;

DefineGlobalColor("Before Earnings", Color.YELLOW);
DefineGlobalColor("Earnings Release Date", Color.YELLOW);
DefineGlobalColor("After Earnings", Color.CYAN);
DefineGlobalColor("Fill Before", CreateColor(178, 216, 166));
DefineGlobalColor("Fill After", CreateColor(131, 191, 213));

AddVerticalLine(showLines and HasEarnings()[-daysBefore], Concat(daysBefore, " Days Before" ), GlobalColor("Before Earnings" ), Curve.FIRM);
AddVerticalLine(showLines and HasEarnings(), "Earnings!", GlobalColor("Earnings Release Date" ), Curve.FIRM);
AddVerticalLine(showLines and HasEarnings()[daysAfter], Concat(daysAfter, " Days After" ), GlobalColor("After Earnings" ), Curve.FIRM);

def before = Sum(HasEarnings(), daysBefore)[-daysBefore];
def after = Sum(HasEarnings(), daysAfter)[1];

def value1 = Double.Positive_Infinity;
def value2 = if paintBackground and before then Double.Negative_Infinity else Double.NaN;
def value3 = if paintBackground and after  then Double.Negative_Infinity else Double.NaN;

AddCloud(value1, value2, GlobalColor("Fill Before" ));
AddCloud(value1, value3, GlobalColor("Fill After" ));
Is there something similar that can be shown for Dividends ?
 

Similar threads

Top