Johnny Cash
Member
Worked, thank you.Try expanding the bar spacing on your chart to 30 days and then it should display the correct date.
Worked, thank you.Try expanding the bar spacing on your chart to 30 days and then it should display the correct date.
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
# 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
Hi all,
I got only the first label even if less than four days remain to the Earning days.
Anyone know why?!
AddLabel(1, NextEarnings, if NextEarnings <= 4 then Color.Red else Color.Current);
AbsValue(GetEventOffset(Events.EARNINGS, 0));
# 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
https://usethinkscript.com/threads/earnings-scan.123/#post-724
def Earnings = AbsValue(GetEventOffset(Events.EARNINGS, 0));
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. ThanksHello 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
hi markos,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
@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.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?
Start a new thread and receive assistance from our community.
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.
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.