NexusFi: Find Your Edge


Home Menu

 





How do you make an Earnings date study?


Discussion in ThinkOrSwim

Updated
      Top Posters
    1. looks_one grendel54 with 2 posts (0 thanks)
    2. looks_two optiontrader101 with 1 posts (4 thanks)
    3. looks_3 trepidation with 1 posts (0 thanks)
    4. looks_4 Whitepineapple with 1 posts (0 thanks)
    1. trending_up 7,557 views
    2. thumb_up 5 thanks given
    3. group 7 followers
    1. forum 8 posts
    2. attach_file 2 attachments




 
Search this Thread
  #1 (permalink)
grendel54
La Crescenta
 
Posts: 4 since Nov 2016
Thanks Given: 1
Thanks Received: 0

I would like to create an upper chart study that has the Earnings date on it...is there a way to do this? If so, please share.

Josh


Reply With Quote

Can you help answer these questions
from other members on NexusFi?
CME Launches Bitcoin Volatility Futures June 1 -- First …
Cryptocurrency
Thanks Mike. Godspeed.
The Elite Circle
Topstep Acquires The Futures Desk -- Prop Firm Consolida …
Funded Trading Evaluation Firms
After $87M Settles NO: Irans Nuclear Redline Sets Up the …
Prediction Markets & Event Contracts
Probability Collapse: Bitcoin $150k Craters from 15% to …
Prediction Markets & Event Contracts
 
Best Threads (Most Thanked)
in the last 7 days on NexusFi
Big Mike in Ecuador
205 thanks
Sober Journey With S&P
21 thanks
30 Sessions
20 thanks
Volume Indicators
8 thanks
Thanks Mike. Godspeed.
7 thanks
  #2 (permalink)
optiontrader101
ON venus
 
Posts: 17 since Nov 2016
Thanks Given: 1
Thanks Received: 8


grendel54 View Post
I would like to create an upper chart study that has the Earnings date on it...is there a way to do this? If so, please share.

Josh



input daysBefore = 5;
input daysAfter = 5;

input showLines = yes;
input paintBackground = yes;

DefineGlobalColor("Before Earnings", Color.GREEN);
DefineGlobalColor("Earnings Release Date", Color.YELLOW);
DefineGlobalColor("After Earnings", Color.CYAN);
DefineGlobalColor("Fill Before", CreateColor(178, 216, 166));
DefineGlobalColor("Fill After", CreateColor(131, 191, 213));

AddVerticalLine(showLines and HasEarnings(), "Earnings!", GlobalColor("Earnings Release Date" ), Curve.FIRM);

def before = Sum(HasEarnings(), daysBefore)[-daysBefore];
def after = Sum(HasEarnings(), daysAfter)[1];

def value1 = HighestAll(high);
def value2 = if paintBackground and before then LowestAll(low) else Double.NaN;
def value3 = if paintBackground and after then LowestAll(low) else Double.NaN;

AddCloud(value1, value2, GlobalColor("Fill Before" ));
AddCloud(value1, value3, GlobalColor("Fill After" ));


Reply With Quote
  #3 (permalink)
grendel54
La Crescenta
 
Posts: 4 since Nov 2016
Thanks Given: 1
Thanks Received: 0


Thank thats great, I like what you did there, but im looking for a way to put the physical date on the chart.

For instance if im looking at a daily chart and dont have the Right Expansion on, I want a small box in the upper left corner that lists the next earnings date.

Next Earnings: 1/7/17


Reply With Quote
  #4 (permalink)
 
DougN's Avatar
 DougN 
Scottsdale, Arizona, USA and Puerto Penasco, Mx
 
Experience: Intermediate
Platform: Ninja 7, TOS
Trading: YM, ES, GC, CL
Posts: 42 since Nov 2013
Thanks Given: 35
Thanks Received: 33

It never ceases to amaze me the outpouring of generosity here in the forum. Thank you for contributing this study optiontrader101! I have a real problem remembering to check earnings dates before entering a swing trade. This will definitely help!


Follow me on X Reply With Quote
  #5 (permalink)
Whitepineapple
Singapore
 
Posts: 1 since Jul 2019
Thanks Given: 0
Thanks Received: 0

Hi, I'm trying to write a code that calculates the average range in earnings of 52 weeks. However, I encounter issues and I can't seem to write it out due to my lack of knowledge in Thinkscript.
I get stuck on finding the range of the previous earnings, I think it has got to do with defining the date of the earnings. Below is the code that's as far as I get.
Kindly appreciate if anyone is able to help out thanks for reading
Cheers

#====================================================
def ear= HasEarnings(EarningTime.BEFORE_MARKET)[1];
def countdown = if ear then getyyYYMMDD() - getyYYYMMDD() else double.nan;
def a = if ear then getyyyymmdd() else double.nan;
def hod = if a then high(period = aggregationperiod.day) else double.nan;
def lod = if a then low(period = aggregationperiod.day) else double.nan;
def range = if a then hod-lod else double.nan;
AddLabel(yes, "range" + range, Color.white);
#====================================================


Reply With Quote
  #6 (permalink)
Nube
Minneapolis Minnesota
 
Posts: 24 since Jul 2019
Thanks Given: 0
Thanks Received: 13


Whitepineapple View Post
Hi, I'm trying to write a code that calculates the average range in earnings of 52 weeks. However, I encounter issues and I can't seem to write it out due to my lack of knowledge in Thinkscript.
I get stuck on finding the range of the previous earnings, I think it has got to do with defining the date of the earnings. Below is the code that's as far as I get.
Kindly appreciate if anyone is able to help out thanks for reading
Cheers

#====================================================
def ear= HasEarnings(EarningTime.BEFORE_MARKET)[1];
def countdown = if ear then getyyYYMMDD() - getyYYYMMDD() else double.nan;
def a = if ear then getyyyymmdd() else double.nan;
def hod = if a then high(period = aggregationperiod.day) else double.nan;
def lod = if a then low(period = aggregationperiod.day) else double.nan;
def range = if a then hod-lod else double.nan;
AddLabel(yes, "range" + range, Color.white);
#====================================================

 
Code
declare lower;

def earnings = GetActualEarnings();
def h = high(period = AggregationPeriod.DAY);
def l = low(period = AggregationPeriod.DAY);
def earningsDayCount;
def earningsDayRangeSum;

if !IsNaN(earnings) {
    earningsDayCount = earningsDayCount[1] + 1;
    earningsDayRangeSum = earningsDayRangeSum[1] + (h - l);
}else{
    earningsDayCount = earningsDayCount[1];
    earningsDayRangeSum = earningsDayRangeSum[1];
}


plot test = earningsDayRangeSum / earningsDayCount;


Reply With Quote
Thanked by:
  #7 (permalink)
apollo23
Singapore
 
Posts: 12 since Feb 2020
Thanks Given: 4
Thanks Received: 2


grendel54 View Post
Thank thats great, I like what you did there, but im looking for a way to put the physical date on the chart.

For instance if im looking at a daily chart and dont have the Right Expansion on, I want a small box in the upper left corner that lists the next earnings date.

Next Earnings: 1/7/17

Really like this idea. Is that possible?

Thanks


Reply With Quote
  #8 (permalink)
 trepidation 
San Jose, California
 
Experience: Intermediate
Platform: Sierra Chart
Posts: 139 since Apr 2018
Thanks Given: 25
Thanks Received: 167

This one is created by Mobius that I found on the web:



 
Code
# Next Earnings Label
# Mobius

def Earnings = AbsValue(GetEventOffset(Events.Earnings, 0));
def NextEarnings = if isNaN(Earnings)
                   then 0
                   else Earnings;
def Month = getMonth();
def year = getYear();
def DOW = getDayOfWeek(getYYYYMMDD());
def today = getDayOfMonth(getYYYYMMDD());
def EarningDay = if NextEarnings + DOW <= 5
                 then NextEarnings + today
                 else if NextEarnings + DOw > 5
                 then NextEarnings + today + 2
                 else NextEarnings;
AddLabel(1, "Next " + getSymbol() + " earnings " + Month + "/" + EarningDay + "/" + AsPrice(year), color.white);
AddLabel(NextEarnings < 30 and NextEarnings > 0,
        "Earnings in " + NextEarnings +
       " trading days", if NextEarnings <= 4
                then Color.Red
                else Color.White);


Reply With Quote
  #9 (permalink)
c0der
Portland + Oregon/United States of America
 
Posts: 8 since Aug 2020
Thanks Given: 0
Thanks Received: 0


trepidation View Post
This one is created by Mobius that I found on the web:

 
Code
# Next Earnings Label
# Mobius

def Earnings = AbsValue(GetEventOffset(Events.Earnings, 0));
def NextEarnings = if isNaN(Earnings)
                   then 0
                   else Earnings;
def Month = getMonth();
def year = getYear();
def DOW = getDayOfWeek(getYYYYMMDD());
def today = getDayOfMonth(getYYYYMMDD());
def EarningDay = if NextEarnings + DOW <= 5
                 then NextEarnings + today
                 else if NextEarnings + DOw > 5
                 then NextEarnings + today + 2
                 else NextEarnings;
AddLabel(1, "Next " + getSymbol() + " earnings " + Month + "/" + EarningDay + "/" + AsPrice(year), color.white);
AddLabel(NextEarnings < 30 and NextEarnings > 0,
        "Earnings in " + NextEarnings +
       " trading days", if NextEarnings <= 4
                then Color.Red
                else Color.White);

I tested this script on DOCU and a few other tickers, and it gives an erroneous date (shows 8/34/2020 as next earnings). Any idea how to correct it? Thank you.


Attached Thumbnails
Click image for larger version

Name:	image_926.png
Views:	311
Size:	19.9 KB
ID:	304595  
Reply With Quote




Last Updated on August 31, 2020


© 2026 NexusFi®, s.a., All Rights Reserved.
Av Ricardo J. Alfaro, Century Tower, Panama City, Panama, Ph: +507 833-9432 (Panama and Intl), +1 888-312-3001 (USA and Canada)
All information is for educational use only and is not investment advice. There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
About Us - Contact Us - Site Rules, Acceptable Use, and Terms and Conditions - Downloads - Top
no new posts