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 Wedge detection #712

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

Pattern: Add Wedge detection #712

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

Comments

@kenorb
Copy link
Member

kenorb commented Aug 17, 2023

bool IsValidWedge(int startIndex, int totalBars, const double &high[], const double &low[], int direction)
{
    double trendlineSlope = (high[startIndex] - low[startIndex]) / 2;
    double prevSlope = 0;

    for (int i = startIndex; i > startIndex - totalBars; i--)
    {
        double slope = (high[i] - low[i]) / 2;
        
        if (direction * slope < 0)
            return false;

        if (direction * prevSlope > 0)
            return false;

        prevSlope = slope;

        if (MathAbs(slope) > MathAbs(trendlineSlope))
            return false;
    }

    return true;
}
@kenorb kenorb added this to the v3.003 milestone 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