Label Showing Next Earnings Date?

scottsamesame

New member
Does anyone know of a thinkscript that will provide a label of when the next earnings date is? Ideally it would show the date and the # of days until the earnings date. TY
 
Solution
Does anyone know of a thinkscript that will provide a label of when the next earnings date is? Ideally it would show the date and the # of days until the earnings date. TY

Use this on a Daily chart with an expansion set to 100 at the settings/time axis tab.

Screenshot-2023-02-28-164650.png
Code:
#Earnings_Date_DaysTill

def div1    = GetEventOffset(eventType = Events.EARNINGS);
def nodiv   = if IsNaN(div1) then -99 else GetEventOffset(eventType = Events.EARNINGS);
def div     = if nodiv == 0 then 1 else 0;
def divday  = if div == 1 then GetYYYYMMDD() else Double.NaN;
def divdate = (HighestAll(divday));
def year    = RoundDown(divdate / 10000, 0);
def month   = RoundDown(((divdate - RoundDown(divdate, -4)) / 100), 0);
def day     = (divdate - (year...
Does anyone know of a thinkscript that will provide a label of when the next earnings date is? Ideally it would show the date and the # of days until the earnings date. TY

Use this on a Daily chart with an expansion set to 100 at the settings/time axis tab.

Screenshot-2023-02-28-164650.png
Code:
#Earnings_Date_DaysTill

def div1    = GetEventOffset(eventType = Events.EARNINGS);
def nodiv   = if IsNaN(div1) then -99 else GetEventOffset(eventType = Events.EARNINGS);
def div     = if nodiv == 0 then 1 else 0;
def divday  = if div == 1 then GetYYYYMMDD() else Double.NaN;
def divdate = (HighestAll(divday));
def year    = RoundDown(divdate / 10000, 0);
def month   = RoundDown(((divdate - RoundDown(divdate, -4)) / 100), 0);
def day     = (divdate - (year * 10000)) - (month * 100);
AddLabel(1, "Next Earnings | Date: " + month + "/" + day + "/" + (year-2000) +
            " | Trading Days Till: " + absvalue(div1), color.white);

input test = yes;
addverticalLine(test and getyyyYMMDD()==divday, "                        " + asprice(divday), color.white, Curve.FIRM);
;
 
Solution

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

Why does it need the 100 expansion area? Will it not work otherwise?
No, it won't work otherwise. If you want the future date, you obviously need to make that allowance in the time axis.
A workaround: you can make a small detached chart with just that little label. Add it to your grid or pin it above your chart.
VFgKAgg.png

shared chart link: http://tos.mx/hBATPhU Click here for --> Easiest way to load shared links
 
Why does it need the 100 expansion area? Will it not work otherwise?
@scottsamesame If I understand the issue correctly, I did the following to fix the future earnings date issue:

Chart Settings > Time Axis > Autoexpand to fit > (Check) Corporate Actions.

Expansion area = 0 bars to the rights. It is sometimes an annoying waste of chart space, but maybe these settings will help with showing the future earnings dates by default on the Time Axis and allow the script to work better.
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

87k+ Posts
199 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