Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Average Range in Earnings for 52 weeks #4

Open
Whitepineapple opened this issue Jul 22, 2019 · 0 comments
Open

Average Range in Earnings for 52 weeks #4

Whitepineapple opened this issue Jul 22, 2019 · 0 comments

Comments

@Whitepineapple
Copy link

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);
#====================================================

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant