Highlight Days Around Earnings

SmellyCat

New member
I will post code that appears to be open to the public.
In the header it credits the original scripter.

I am wondering if it is possible for someone to add a couple of options to this indicator to:
Can the two clouds be colored according to the price action from 21 days before earnigns to the close of the day before earnings?
If it was a positive number, then color a custom RBG color? If negative the opposite?
The second cloud would be from the close of earnings day to a selected number of days post earnings?
Again, if positive or negative, color code the cloud.

further, could the run into earnings be color coded to show a low rise one color, a higher rise a brighter color?

i like this little gem I found. Would like some additions. \i have tried but only to muck it up.


#Highlight days around earnings #Robert Payne #http://rrpayne.blogspot.com

input daysBefore = 21;
input daysAfter = 10;
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(180, 215, 165));
DefineGlobalColor("Fill After", CreateColor(130, 190, 215));

AddVerticalLine(showLines and HasEarnings()[-daysBefore], Concat(daysBefore, " Days Before" ), GlobalColor("Before Earnings" ), Curve.FIRM);

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

AddVerticalLine(showLines and HasEarnings()[daysAfter], Concat(daysAfter, " Days After" ), GlobalColor("After Earnings" ), Curve.FIRM);

def before = Sum(HasEarnings(), daysBefore)[-daysBefore];
def after = Sum(HasEarnings(), daysAfter)[1];
def value1 = Double.Positive_Infinity;
def value2 = if paintBackground and before then Double.Negative_Infinity else Double.NaN;
def value3 = if paintBackground and after then Double.Negative_Infinity else Double.NaN;

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

Similar threads

Top