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

Pattern: Add Gartley pattern #711

Open
kenorb opened this issue Aug 17, 2023 · 0 comments
Open

Pattern: Add Gartley pattern #711

kenorb opened this issue Aug 17, 2023 · 0 comments
Assignees
Milestone

Comments

@kenorb
Copy link
Member

kenorb commented Aug 17, 2023

Detects a harmonic pattern called the Gartley pattern.

Example code:

//+------------------------------------------------------------------+
//| Function to check if a Gartley pattern is present         |
//+------------------------------------------------------------------+
bool IsGartleyPattern(int index, const double &high[], const double &low[])
{
    double XA = high[index - 4] - low[index - 4];
    double AB = high[index - 3] - low[index - 3];
    double BC = high[index - 2] - low[index - 2];
    double CD = high[index - 1] - low[index - 1];

    double ABtoXA = AB / XA;
    double BCtoAB = BC / AB;
    double CDtoBC = CD / BC;

    bool isGartleyPattern = (ABtoXA >= 0.618 && ABtoXA <= 0.786) &&
                            (BCtoAB >= 0.382 && BCtoAB <= 0.886) &&
                            (CDtoBC >= 1.618 && CDtoBC <= 2.618);

    return isGartleyPattern;
}
@kenorb kenorb added this to the v3.003 milestone Aug 17, 2023
@kenorb kenorb self-assigned this Aug 17, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant