Next Earning Date Indicator for ThinkorSwim

BenTen

BenTen

Administrative
Staff
VIP
Found this indicator created by Mobius while I was browsing the thinkScript Lounge. It adds 2 labels on your chart. One shows the next earning date for the stock. If the upcoming earning date is within 5 days it will also add a bright red warning. Sort of acts as an attention grabber to let you know.



thinkScript Code

Code:
# Next Earnings Label
# Mobius

def Earnings = AbsValue(GetEventOffset(Events.Earnings, 0));
def NextEarnings = if isNaN(Earnings)
                   then 0
                   else Earnings;
def Month = getMonth();
def year = getYear();
def DOW = getDayOfWeek(getYYYYMMDD());
def today = getDayOfMonth(getYYYYMMDD());
def EarningDay = if NextEarnings + DOW <= 5
                 then NextEarnings + today
                 else if NextEarnings + DOw > 5
                 then NextEarnings + today + 2
                 else NextEarnings;
AddLabel(1, "Next " + getSymbol() + " earnings " + Month + "/" + EarningDay + "/" + AsPrice(year), color.white);
AddLabel(NextEarnings < 30 and NextEarnings > 0,
        "Earnings in " + NextEarnings +
       " trading days", if NextEarnings <= 4
                then Color.Red
                else Color.White);

Shareable Link


Warning: Some users have pointed out that this indicator and the data it provides may be inconsistent. An alternative script has been posted here.
 
Last edited:
L

laketrader

New member
2019 Donor
VIP
Like this script. But it did not display the date correctly for some ticker. e.g.

 
dougn

dougn

Member
2019 Donor
Although the creator is unknown...this one marks the chart and the user can add a shaded area for the number of days before and after the date...or none at all...just a line.

input daysBefore = 5;
input daysAfter = 5;

input showLines = yes;
input paintBackground = yes;

DefineGlobalColor("Before Earnings", Color.GREEN);
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(), "Earnings!", GlobalColor("Earnings Release Date" ), Curve.FIRM);

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

def value1 = HighestAll(high);
def value2 = if paintBackground and before then LowestAll(low) else Double.NaN;
def value3 = if paintBackground and after then LowestAll(low) else Double.NaN;

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

Nick

Active member
2019 Donor
VIP
Thanks ben, i like this scan too. But i would like to know if this scan can be configure to scan out stocks that are reporting earning in the next 30 - 40 days?
 
zeek

zeek

Active member
2019 Donor
Anyone else having issues with this script? It doesn`t seem to work because no matter which chart i open, it says "Next Earnings in todays date". I havn`t found one single stock where it says "earnings in x trading days".

What am i missing here?
 
V

Vision

New member
2019 Donor
Unfortunately the Mobius script gives the wrong date on what I tried it on, BHC.
 
markos

markos

Well-known member
VIP
Blame it on a Tos update, just like the one that broke the scanner a year ago.
Actually, this label needs the expansion open 50 bars or so to work. It only sees what is on the chart.
IMO, you're best off using the selection "show corporate actions" in the settings.
 
AGD

AGD

New member
Try This

#################
# ER Labels
#################
def daysBefore = 100;
def erInDays = AbsValue(GetEventOffset(Events.EARNINGS, 0));
def before = Sum(HasEarnings(), daysBefore)[-daysBefore];
AddLabel(Yes, IF before THEN "ER: "+erInDays+" days" ELSE "ER: No", IF before THEN Color.RED ELSE Color.GREEN);
 
zeek

zeek

Active member
2019 Donor
@AGD Says "ER:No" no matter what symbol i input. Tried several companies with upcoming earnings.
 
J

Johnny Cash

Member
I like this indicator, but it is not displaying the dates correctly. am i doing something wrong?
 
J

jox51

Member
2019 Donor
VIP
Try expanding the bar spacing on your chart to 30 days and then it should display the correct date.
 
J

jox51

Member
2019 Donor
VIP
For earnings, if you don't want to mess with the chart another alternative is below. Below indicator is watchlist column that lets you know the days till earnings if within 30 days. If more than 30, the watchlist column will just say 30. If under 4 days till earnings, will highlight the number in red.

Code:
# WatchList Days Till Earnings 

# If over 30 days away shows 30 

# Mobius 

def LastEarningsBar = AbsValue(GetEventOffset(Events.Earnings, 0));

def NextEarnings = if isNaN(LastEarningsBar) then 0 else LastEarningsBar;

AddLabel(1, NextEarnings, if NextEarnings <= 4 then Color.Red else Color.Current); 

# End WatchList Code for X Earnings  
https://tos.mx/vHhzS9

This is another watchlist column that shows next earnings date.

 
S

Sonima

New member
Hi all,
I got only the first label even if less than four days remain to the Earning days.
Anyone know why?!
 
T

tomsk

Well-known member
VIP
Hi all,
I got only the first label even if less than four days remain to the Earning days.
Anyone know why?!
If you read the code, it says it will display the label in RED in there are 4 or less days remaining to earnings, i.e. 4, 3, 2, 1

AddLabel(1, NextEarnings, if NextEarnings <= 4 then Color.Red else Color.Current);
 
S

Sonima

New member
I won't get the red box, even if there are 3 days to earning!
 
Top