• Get $40 off VIP by signing up for a free account! Sign Up

Next Earnings Column / Label For ThinkOrSwim

LLP

Member
How to make this Earning date shows at the SCAN TAB?
Please see pic.1 + pic2. explanation. Thanks!
 

Attachments

  • Screenshot (93).earing.used.01.png
    Screenshot (93).earing.used.01.png
    819.4 KB · Views: 70
  • Screenshot 2024-07-02 145829.earning.used.02.png
    Screenshot 2024-07-02 145829.earning.used.02.png
    203.1 KB · Views: 69

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

this actually took me forever to figure out how to get past the 30D forward looking bar (days) restriction in ToS. Learned a few things.

here you go
NEXT EARNINGS DATE WITH BEFORE OPEN OR AFTER MARKET CLOSE LABEL or COLUMN v3.0
NOTE: THE CODE IS ADJUSTABLE TO SHOW WITH OR WITHOUT THE DATE

AS A COLUMN:
*MUST BE ON DAY AGGREGATION <-------- PEOPLE WILL STILL FORGET THIS AND SAY IT DOESN'T WORK, BUT IT DOES WORK
.
.
AS A CHART LABEL:
go to CHARTS SETTINGS>TIME AXIS>
*MUST BE ON DAY AGGREGATION & EXPANSION AREA 100 BARS TO RIGHT <-------- PEOPLE WILL STILL FORGET THIS AND SAY IT DOESN'T WORK, BUT IT DOES WORK


Code:
declare lower;
# NEXT EARNINGS DATE WITH BEFORE OPEN OR AFTER MARKET CLOSE LABEL or COLUMN v3.0
# by request via usethinkscript.com by XeoNoX 07/07/2024
#      *****************************************************
#      *****  AS COLUMN MUST BE ON DAY AGGREGATION    ******
#   
#
#      ****** IF USING ON A CHART MUST SET     ******
#      ******      AGGREGATION TO DAY          ******
#      ******           AND                    ******
#      ****** EXPANSION AREA 100 BARS TO RIGHT ******
#      ****** Go to CHART SETTINGS > TIME AXIS ******
#      *****************************************************
############################################################
#INPUT "YES" or "NO" TO SHOW YEAR
input showyear=YES;
########################################
#Special thanks to @Joshua/@Paris from usethinkscript.com for the 30D limitation bypass
#30D Bypass CODE START
def length = close[-93];
def ER = geteventOffset(events.earnings) + (isNaN(length) * 0);
def ERbar = if !isNaN(close) then ER else ERbar[1];
def daysaway = absValue(ERbar);
#30D Bypass CODE END
##########################################
def before = HasEarnings(type = EarningTime.BEFORE_MARKET);
def after = HasEarnings(type = EarningTime.AFTER_MARKET);
def beforebar = if before then (BarNumber()) else beforebar[1];
def afterbar = if after then (BarNumber()) else afterbar[1];
def beforebarh = HighestAll(beforebar);
def affterbarh = HighestAll(afterbar);
def BarIsAfter = if  affterbarh > beforebarh then 1 else  0;
def lastbar = (if IsNaN(close[-1]) and !IsNaN(close) then BarNumber() else Double.NaN);
def day  = HighestAll(if BarNumber() == HighestAll(lastbar + daysaway) then GetDayOfMonth(GetYYYYMMDD()) else Double.NaN);
def month  = HighestAll(if BarNumber() == HighestAll(lastbar + daysaway) then GetMonth() else Double.NaN);
def year = HighestAll(if BarNumber() == HighestAll(lastbar + daysaway) then GetYear() - 2000 else Double.NaN);
AddLabel(1,  if ISNAN(day) then "No Earnings" else (if month>9 then "" else "0") + month+ "/" + (if day>9 then "" else "0")+ day + "/"+ (if ShowYear==YES then asprice(year) else "") + (if BarIsAfter then " (A)" else  " (B)" ), Color.gray);

NOTE: THE CODE IS ADJUSTABLE TO SHOW EITHER WITH OR WITHOUT THE DATE

SCREENSHOT OF WITHOUT THE YEAR
1720402074755.png


SCREENSHOT WITH THE YEAR

1720402129134.png
 
Last edited:
this actually took me forever to figure out how to get past the 30D forward looking bar (days) restriction in ToS. Learned a few things.

here you go
NEXT EARNINGS DATE WITH BEFORE OPEN OR AFTER MARKET CLOSE LABEL or COLUMN v1.0
NOTE: THE CODE IS ADJUSTABLE TO SHOW WITH OR WITHOUT THE DATE
*MUST BE ON DAY AGGREGATION <-------- PEOPLE WILL STILL FORGET THIS AND SAY IT DOESN'T WORK, BUT IT DOES WORK

Code:
declare lower;
# NEXT EARNINGS DATE WITH BEFORE OPEN OR AFTER MARKET CLOSE LABEL or COLUMN v2.0
# by request via usethinkscript.com by XeoNoX 07/07/2024
#           *********************************
#           ****MUST BE ON DAY AGGREGATION***
#           *********************************
#######################################
#INPUT "YES" or "NO" TO SHOW YEAR
input showyear=YES;
########################################
#Special thanks to @Joshua/@Paris from usethinkscript.com for the 30D limitation bypass
#30D Bypass CODE START
def length = close[-93];
def ER = geteventOffset(events.earnings) + (isNaN(length) * 0);
def ERbar = if !isNaN(close) then ER else ERbar[1];
def daysaway = absValue(ERbar);
#30D Bypass CODE END
##########################################
def before = HasEarnings(type = EarningTime.BEFORE_MARKET);
def after = HasEarnings(type = EarningTime.AFTER_MARKET);
def beforebar = if before then (BarNumber()) else beforebar[1];
def afterbar = if after then (BarNumber()) else afterbar[1];
def beforebarh = HighestAll(beforebar);
def affterbarh = HighestAll(afterbar);
def BarIsAfter = if  affterbarh > beforebarh then 1 else  0;
def lastbar = (if IsNaN(close[-1]) and !IsNaN(close) then BarNumber() else Double.NaN);
def day  = HighestAll(if BarNumber() == HighestAll(lastbar + daysaway) then GetDayOfMonth(GetYYYYMMDD()) else Double.NaN);
def month  = HighestAll(if BarNumber() == HighestAll(lastbar + daysaway) then GetMonth() else Double.NaN);
def year = HighestAll(if BarNumber() == HighestAll(lastbar + daysaway) then GetYear() - 2000 else Double.NaN);
AddLabel(1,  if ISNAN(day) then "No Earnings" else (if month>9 then "" else "0") + month+ "/" + (if day>9 then "" else "0")+ day + "/"+ (if ShowYear==YES then asprice(year) else "") + (if BarIsAfter then " (A)" else  " (B)" ), Color.gray);

NOTE: THE CODE IS ADJUSTABLE TO SHOW EITHER WITH OR WITHOUT THE DATE

SCREENSHOT OF WITHOUT THE YEAR
View attachment 22323

SCREENSHOT WITH THE YEAR

View attachment 22324
it always shows the same date for all stocks
 
it always shows the same date for all stocks

oh, i think i know what you did, it works fine on Columns just setting aggegation. But on a chart as a label you have to take an extra step and set the expansion area as well. please make sure you have a minimum of 3 months (atleast 100 days), which in this case are bars) visible both forward looking and back looking on the daily chart. thanks for bringing this to my attention, i will update the original post with this information.

dayagg.png
 
Last edited:
oh, i think i know what you did, it works fine on Columns just setting aggegation. But on a chart as a label you have to take an extra step and set the expansion area as well. please make sure you have a minimum of 3 months (atleast 100 days), which in this case are bars) visible both forward looking and back looking on the daily chart. thanks for bringing this to my attention, i will update the original post with this information.

View attachment 22338
Thanks XeoNox, it works perfectly by changing the expansion area. Thank you!
 

Similar threads

Not the exact question you're looking for?

Start a new thread and receive assistance from our community.

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