# 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
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);
# 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
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
@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?
|Thread starter||Similar threads||Forum||Replies||Date|
|Earnings Regression Std Deviation for ThinkorSwim||Indicators||8|
|Earnings, Dividend and P/E Labels for ThinkorSwim||Indicators||10|
|T||Days Until Earnings Watchlist for ThinkorSwim||Indicators||8|
|Expected Earnings Predictions Indicator for ThinkorSwim||Indicators||20|
|Historical Earnings Trend Indicator for ThinkorSwim||Indicators||29|