Skip to content

Average Range in Earnings for 52 weeks #4

Open
@Whitepineapple

Description

@Whitepineapple

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions