ThinkorSwim Earnings Date Indicator and Watchlist Column

Status
Not open for further replies.

Join useThinkScript to post your question to a community of 21,000+ developers and traders.

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.

https://usethinkscript.com/threads/...or-for-thinkorswim-as-watchlist.926/post-6551
 
Hi all, I got only the first label even if less than four days remain to the Earning days. Anyone know why?!
 
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

Code:
AddLabel(1, NextEarnings, if NextEarnings <= 4 then Color.Red else Color.Current);
 
Make sure you have sufficient bars defined in your expansion area. If you do not do this, you won't see the data. Check that you are using DAILY aggregation.

Go to Settings > Time Axis > Expansion area. I set mine to 22 bars to the right
 
Many thanks tomsk, appritiate your swift reply.
There should be some error there for me.
This always returns N/A for me!
Code:
AbsValue(GetEventOffset(Events.EARNINGS, 0));

It is strange as it works fine in the watchlist column, but not on the chart. Even in the watchlist, days to earning is always correct, but not Earning date!
 
Be very specific as to where you're seeing the error - scanner, watchlist, chart, strategy.
If you're just using that single line of code in post #24 above, I can GUARANTEE it won't work
Post your entire code, let us know where you're using it, what symbol, what aggregation so that someone will have the details to help you.
@BenTen has always said to be specific and to provide all the relevant info.
Saying things like it doesn't work - has no meaning otherwise
 
Hi again!
Entire code is posted at the first post of this topic (and several times after) and thus no need for repetition I guess.
I was specific I believe:
"It works fine in the watchlist column, but not on the chart".
Regardless of the symbol, it won't work on the chart on a daily time frame. I have also extended the chart by 30 bars to the right.
Thanks again.
 
@Sonima Ah! Now we are getting somewhere. I immediately see where the problem is. When this code was released in the ThinkScript Lounge months ago, several people pointed out that that code is FUBAR. Do not use that as it is inaccurate. Let me give you an example. Load the study that was posted in post #1 of this thread. Set your aggregation to DAILY and load up ticker symbol C. Just to be sure I have my expansion space set to 44.

What happens? Notice that that particular study reports that the next C earnings is on 12/33/2019. That is clearly wrong.

@BenTen Please take note and either DELETE or TAG that study as being inconsistent.

As a workaround, I have a study that I obtained from a long standing contributor in the ThinkScript Lounge. That study works much better and is an improved version over the original release that was created 4-5 years ago. It correctly reports that ticker C will report earnings in 25 days, on 1/14/2020.

Here is the code

Code:
# Next Earnings Date
# Paris
# 10.15.2019

# You have to have enough expansion area on your chart available to reach the actual Earnings date, so if you have 0 expansion area, an inconsistent date will be displayed

#HINT: watchlist label that shows days-to-earnings and next earnings date (if next earnings date is available).  Includes a visual alert if "EARNINGS TODAY"

#def allows you to teach ThinkScript new "words" to save time and typing by using your new "words" later in the code
def bn = BarNumber();
def na = Double.NaN;
def getNextEarnings = AbsValue(GetEventOffset(Events.EARNINGS, 0));
def findDay = GetDayOfMonth(GetYYYYMMDD());
def findMonth = GetMonth();
def findYear = GetYear();

#ThinkScript thinks in numbers, including converting dates into numbers and viewing each bar on the chart as a number.  Therefore you can use BarNumber to tell ThinkScript which bar, and use lines in ThinkScript code to 'trick' ThinkScript into displaying that daily bar in date format
def getNextEarningsBarNumber = if !isNaN(getNextEarnings) then bn + getNextEarnings else na;
def NextEarnings = bn == HighestAll(getNextEarningsBarNumber);
def getNextEarningsMonth = HighestAll(if NextEarnings then findMonth else na);
def getNextEarningsDay = HighestAll(if NextEarnings then findDay else na);
def getNextEarningsYear = HighestAll(if NextEarnings then findYear else na);

#plot tells ThinkScript what data you want displayed.  Hide() is used in this case because desired display is the label and not the numberic equivalent of the data
plot DaysToEarnings = getNextEarningsBarNumber;
DaysToEarnings.Hide();

AddLabel(getNextEarnings > 0, "Next Earnings: (" + getNextEarnings + (if getNextEarnings == 1 then " Day): " else " Days): ") + getNextEarningsMonth + "/" + getNextEarningsDay + "/" + AsPrice(getNextEarningsYear), Color.Pink);
AddLabel(getNextEarnings == 0, "  EARNINGS TODAY ", Color.Yellow);
# End Next Earnings Date
 
Last edited:
Thank you, @tomsk, for the heads up. I just made some notes regarding this issue in the original thread.
 
Hi!
The code you have posted is very similar to this:
Code:
https://usethinkscript.com/threads/earnings-scan.123/#post-724

These scripts work perfect in the watchlist but not on the chart. I redirect you to my first post. As far as TOS return N/A for the Earnings in the below line of the code, then none of such scripts works on charts!

Code:
def Earnings = AbsValue(GetEventOffset(Events.EARNINGS, 0));

Thanks anyway for your time and answer.
 
@Sonima Your post yesterday specified that the script you used worked on the watchlist but not on the charts, Hence I started to look into the problem with the charts.

Please READ post #27, it tells you VERY CLEARLY how to resolve the issue on the charts. Yes I believe the version posted was based on Cindy's scripts from 2015, the difference is that Cindy's was written specifically for the watchlist. The version I posted was modified to work on the charts.

Since you specify you have no problems with your watchlist version, we're DONE. I won't be spending any more time on this issue
 
Last edited:
Hello all, I tried this indicator on the chart and still get the wrong date. I updated the expansion bars to 22 and have it on a daily chart like @tomsk instructed. For example, ticker D for Dominion TOS analyze thab-> earnings shows next earnings date as 2/10/2020 but pink label on the chart says 2/11/2020. I tried several tickers and they all have the wrong date. How do I fix it? Thanks
 
@ansheth I like this indicator because it tells if earnings is before or after market but above you said you fixed the problem and did not post the completed corrected code. Is this the fix and if so how to add it to the original code you posted? I'm not a coder so you need to be explicit, Thanks
 
Last edited by a moderator:
Hello all, I tried this indicator on the chart and still get the wrong date. I updated the expansion bars to 22 and have it on a daily chart like @tomsk instructed. For example, ticker D for Dominion TOS analyze thab-> earnings shows next earnings date as 2/10/2020 but pink label on the chart says 2/11/2020. I tried several tickers and they all have the wrong date. How do I fix it? Thanks
If you can't get what @tomsk put here to work for you, spend the weekend with the Universe of Thinkscript in our Tutorials Section. Thanks
 
If you can't get what @tomsk put here to work for you, spend the weekend with the Universe of Thinkscript in our Tutorials Section. Thanks
hi markos,
im sure this is a frequent question. im only able to use tos mobile from work. is there anyway of translating these codes to mobile? or is it more trial and error?
 
hi markos,
im sure this is a frequent question. im only able to use tos mobile from work. is there anyway of translating these codes to mobile? or is it more trial and error?
@Orios Hi, i also spend most of my time on .mobile. I wrote a post in the Tutorial section for this situation. It's mostly trial and error other than what's written in there. Good luck.
 
Hey, just an observation. I was told we cant use labels on mobile. May have found a tricky workaround. You can set alerts and that will show our labels. Trying to do Market Sentiment/Adv Decliners. Very tricky though
 
Status
Not open for further replies.

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
431 Online
Create Post

Similar threads

Similar threads

The Market Trading Game Changer

Join 2,500+ subscribers inside the useThinkScript VIP Membership Club
  • Exclusive indicators
  • Proven strategies & setups
  • Private Discord community
  • ‘Buy The Dip’ signal alerts
  • Exclusive members-only content
  • Add-ons and resources
  • 1 full year of unlimited support

Frequently Asked Questions

What is useThinkScript?

useThinkScript is the #1 community of stock market investors using indicators and other tools to power their trading strategies. Traders of all skill levels use our forums to learn about scripting and indicators, help each other, and discover new ways to gain an edge in the markets.

How do I get started?

We get it. Our forum can be intimidating, if not overwhelming. With thousands of topics, tens of thousands of posts, our community has created an incredibly deep knowledge base for stock traders. No one can ever exhaust every resource provided on our site.

If you are new, or just looking for guidance, here are some helpful links to get you started.

What are the benefits of VIP Membership?
VIP members get exclusive access to these proven and tested premium indicators: Buy the Dip, Advanced Market Moves 2.0, Take Profit, and Volatility Trading Range. In addition, VIP members get access to over 50 VIP-only custom indicators, add-ons, and strategies, private VIP-only forums, private Discord channel to discuss trades and strategies in real-time, customer support, trade alerts, and much more. Learn all about VIP membership here.
How can I access the premium indicators?
To access the premium indicators, which are plug and play ready, sign up for VIP membership here.
Back
Top