@soary Did you ever get this fixed? If not, please post in the questions forum, hopefully you will get a bite.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
@ezrollin If you got this to work, would you share in a new thread? Thanks.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
def bn = BarNumber();
def na = Double.NaN;
def getNextEarnings = AbsValue(GetEventOffset(Events.EARNINGS, 0));
def findDay = GetDayOfMonth(GetYYYYMMDD());
def findMonth = GetMonth();
def findYear = GetYear();
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 DaysToEarnings = getNextEarningsBarNumber;
DaysToEarnings.Hide();
AddLabel(getAggregationPeriod()==aggregationPeriod.DAY and getNextEarnings > 0, "Next Earnings: (" + getNextEarnings + (if getNextEarnings == 1 then " Day): " else " Days): ") + getNextEarningsMonth + "/" + getNextEarningsDay + "/" + AsPrice(getNextEarningsYear), Color.Pink);
AddLabel(getAggregationPeriod()==aggregationPeriod.DAY and getNextEarnings == 0, "EARNINGS TODAY", Color.Yellow);
#For Watch List Column: This code originaly from Thinkscript Lounge at TOS circa 2017
#I use this one because it tells me xx.0= earns before market & xx.5 = earns after market close.
#Please notice that it counts down starting at 60 days and is adjustable via UI. Markos at usethinkscript.com
input length = 60;
def xx= -geteventOffset(events.EARNINGS);
def yy = sum(hasEarnings(type = earningTime.AFTER_MARKET),length)[-length +1] >0;
plot x=xx+yy*.5;
x.assignvaluecolor( if yy!=0 then color.LIGHT_RED else color.Yellow);
#original nextearnings
declare lower;
def bn = BarNumber();
def na = Double.NaN;
def getNextEarnings = absvalue(GetEventOffset(Events.EARNINGS, 0));
def findDay = GetDayOfMonth(GetYYYYMMDD());
def findMonth = GetMonth();
def findYear = GetYear();
#getnextearningsbarnumber is confusing but for setting the mo/d/yr
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);
#different nextearnings with aftermarket is .5 and whole number is before or during market hours
input length = 63;
def xx= -geteventOffset(events.EARNINGS);
def yy = sum(hasEarnings(type = earningTime.AFTER_MARKET),length)[-length +1] >0;
plot DaysToEarnings = xx+yy*.5;
DaysToEarnings.assignvaluecolor( if yy!=0 then color.LIGHT_RED else color.Yellow);
#labels for original nextearnings with different nextearnings data
AddLabel(getAggregationPeriod()==aggregationPeriod.DAY and getNextEarnings > 0, "Earnings: (" + DaysToEarnings + (if getNextEarnings == 1 then " Day) " else " Days) ") + getNextEarningsMonth + "/" + getNextEarningsDay + "/" + AsPrice(getNextEarningsYear), Color.Pink);
#indicators for before or during or after earnings
plot isBefore = HasEarnings(EarningTime.BEFORE_MARKET);
plot isAfter = HasEarnings(EarningTime.AFTER_MARKET);
plot isDuringOrUnspecified = HasEarnings() and !isBefore and !isAfter;
isbefore.setDefaultColor(color.yellow);
isafter.setDefaultColor(color.red);
isduringorunspecified.setDefaultColor(color.orange);
isBefore.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN);
isAfter.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_up);
isDuringOrUnspecified.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
@jngy2k@markos
Ok the best nextearnings indicator i can come up with.
still can't get it to work without expansion unfortuneately
Code:#original nextearnings declare lower; def bn = BarNumber(); def na = Double.NaN; def getNextEarnings = absvalue(GetEventOffset(Events.EARNINGS, 0)); def findDay = GetDayOfMonth(GetYYYYMMDD()); def findMonth = GetMonth(); def findYear = GetYear(); #getnextearningsbarnumber is confusing but for setting the mo/d/yr 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); #different nextearnings with aftermarket is .5 and whole number is before or during market hours input length = 63; def xx= -geteventOffset(events.EARNINGS); def yy = sum(hasEarnings(type = earningTime.AFTER_MARKET),length)[-length +1] >0; plot DaysToEarnings = xx+yy*.5; DaysToEarnings.assignvaluecolor( if yy!=0 then color.LIGHT_RED else color.Yellow); #labels for original nextearnings with different nextearnings data AddLabel(getAggregationPeriod()==aggregationPeriod.DAY and getNextEarnings > 0, "Earnings: (" + DaysToEarnings + (if getNextEarnings == 1 then " Day) " else " Days) ") + getNextEarningsMonth + "/" + getNextEarningsDay + "/" + AsPrice(getNextEarningsYear), Color.Pink); #indicators for before or during or after earnings plot isBefore = HasEarnings(EarningTime.BEFORE_MARKET); plot isAfter = HasEarnings(EarningTime.AFTER_MARKET); plot isDuringOrUnspecified = HasEarnings() and !isBefore and !isAfter; isbefore.setDefaultColor(color.yellow); isafter.setDefaultColor(color.red); isduringorunspecified.setDefaultColor(color.orange); isBefore.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_DOWN); isAfter.SetPaintingStrategy(PaintingStrategy.BOOLEAN_WEDGE_up); isDuringOrUnspecified.SetPaintingStrategy(PaintingStrategy.BOOLEAN_POINTS);
When I try to implement this in my scanned watchlist, I don't get a correct earnings date. What am I doing wrong? See image below please:@ansheth
Rather than adding a label to my charts, I created a simple watchlist column to show the next earnings release date. I have it setup so that if earnings were released within the last 5 days it will show the most recent release date; otherwise it shows next earnings release.
Ruby:# watchlist column for earnings release date # Robert Payne def PE = GetEventOffset(Events.EARNINGS, -1); def NE = GetEventOffset(Events.EARNINGS, 0); def z = if PE <= 5 then PE else NE; # get the earnings date def eDay = GetValue(GetDayOfMonth(GetYYYYMMDD()), z); def eMonth = GetValue(GetMonth(), z); AddLabel(yes, (if eMonth < 10 then "0" else "") + eMonth + " / " + (if eDay < 10 then "0" else "") + eDay, if z <= 0 then Color.CYAN else Color.CURRENT);
Thanks Xeonox...scan for
Has earnings within past XYZ Days (bars) ago
Set to scan to day aggregation
Code:#Has earnings within XYZ Days ago # By XeoNoX Via usethinkscript.com def daysago = 1; def HasER_X_daysago = sum(hasearnings(),daysago) > 0; plot scan = HasER_X_daysago;
Thanks!!scan for
Has earnings within past XYZ Days (bars) ago
Set to scan to day aggregation
Code:#Has earnings within XYZ Days ago # By XeoNoX Via usethinkscript.com def daysago = 1; def HasER_X_daysago = sum(hasearnings(),daysago) > 0; plot scan = HasER_X_daysago;
Hi Xeonox,scan for
Has earnings within past XYZ Days (bars) ago
Set to scan to day aggregation
Code:#Has earnings within XYZ Days ago # By XeoNoX Via usethinkscript.com def daysago = 1; def HasER_X_daysago = sum(hasearnings(),daysago) > 0; plot scan = HasER_X_daysago;
Join useThinkScript to post your question to a community of 21,000+ developers and traders.
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.