Upcoming Earnings Date, Paint the Bars
Author: wmrgrove
Creation Date: 2/7/2018 3:57 PM
profile picture

wmrgrove

#1
Found this excellent example of how to find the next earnings date and paint the chart on Wealth Lab WiKi:

Earnings Date Helper


A few questions;

I changed this line,

CODE:
Please log in to see this code.

from, bar to bar-10 to show the color red on the charts 10 days earlier. For my strategy I do not want to consider an entry 2 weeks before earnings and want to see that on charts.
On the WiKi info it references,
QUOTE:
" barsBefore, barsAfter The number of days before and/or after the earnings date to be considered in the earnings window. For just the earnings date itself, pass 0 for both parameters. "

The strategy example code above does not use those parameters and I have not been able to find more info.
Is barsBefore a better way to accomplish a 2 week alert color on the chart than bar-10, and also bar-10 does not paint the entire 10 bar period till earnings, just a few days.

Second question, for learning purpose only; if I only wanted to paint the upcoming and one previous earning warnings, how would that be accomplished? Would that reduce the "overhead" of running it on multi years?
profile picture

Cone

#2
The EarningsDate.InWindow function returns true on the specified bar when the bar is within the window defined. You need to change the parameters from "2, 1" to "10, 0".. Does this work?

CODE:
Please log in to see this code.


Re: Second question
Overhead isn't a concern for this operation. (And to do it, you would need to add logic, so it makes the script unnecessarily more complex.)
profile picture

Eugene

#3
QUOTE:
The strategy example code above does not use those parameters and I have not been able to find more info.

That's incorrect. Any code that uses InWindow (like the example you cited) always makes use of these parameters as they are required and not optional. As said in the Wiki you referenced, the two parameters define the earnings window from barsBefore through barsAfter. Change the parameters from the default 2 to 10 bars.

QUOTE:
Second question, for learning purpose only; if I only wanted to paint the upcoming and one previous earning warnings, how would that be accomplished? Would that reduce the "overhead" of running it on multi years?

Reduce your data loading range.
profile picture

wmrgrove

#4
Thanks guys, does exactly what I wanted, very cool!

Learning a lot and am using the forum and WiKi to try and answer my own questions. Should have figured this out.
profile picture

wmrgrove

#5
The "Earnings Date" paint the bar modification to my simple chart view works perfectly. Thanks guys!

In Pairs Trading I have a Strategy view that looks at the 2 tickers on one chart at the same time and also displays the RATIO of the two.

The code for that is below; ( the "slider" just allows me to adjust the Std Dev Bands of the RATIO )

CODE:
Please log in to see this code.


The code to "Paint the Bars" in my single ticker view is here;

CODE:
Please log in to see this code.


My question is; can I apply the "Earnings" code to both the selected ticker and the External ticker at the same time and view it on the chart? I realize the "painted area" might over-lab sometimes but that is not a problem. If this can be done then one could see if either of the pair tickers had upcoming earnings in one view. The flexibility of Wealth Lab continues to impress!

Thanks for any help!
profile picture

Eugene

#6
QUOTE:
My question is; can I apply the "Earnings" code to both the selected ticker and the External ticker at the same time and view it on the chart?

Sorry, you can't. The InWindow method is coded in a way that it's always applied to the charted Bars symbol.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).