PINE LIBRARY

PubLibPattern

Updated
Library "PubLibPattern"
pattern conditions for indicator and strategy development

bear_5_0(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol)
  bearish 5-0 harmonic pattern condition
  Parameters:
    ab_low_tol (float)
    ab_up_tol (float)
    bc_low_tol (float)
    bc_up_tol (float)
    cd_low_tol (float)
    cd_up_tol (float)
  Returns: bool

bull_5_0(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol)
  bullish 5-0 harmonic pattern condition
  Parameters:
    ab_low_tol (float)
    ab_up_tol (float)
    bc_low_tol (float)
    bc_up_tol (float)
    cd_low_tol (float)
    cd_up_tol (float)
  Returns: bool

bear_abcd(bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol)
  bearish abcd harmonic pattern condition
  Parameters:
    bc_low_tol (float)
    bc_up_tol (float)
    cd_low_tol (float)
    cd_up_tol (float)
  Returns: bool

bull_abcd(bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol)
  bullish abcd harmonic pattern condition
  Parameters:
    bc_low_tol (float)
    bc_up_tol (float)
    cd_low_tol (float)
    cd_up_tol (float)
  Returns: bool

bear_alt_bat(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol, ad_low_tol, ad_up_tol)
  bearish alternate bat harmonic pattern condition
  Parameters:
    ab_low_tol (float)
    ab_up_tol (float)
    bc_low_tol (float)
    bc_up_tol (float)
    cd_low_tol (float)
    cd_up_tol (float)
    ad_low_tol (float)
    ad_up_tol (float)
  Returns: bool

bull_alt_bat(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol, ad_low_tol, ad_up_tol)
  bullish alternate bat harmonic pattern condition
  Parameters:
    ab_low_tol (float)
    ab_up_tol (float)
    bc_low_tol (float)
    bc_up_tol (float)
    cd_low_tol (float)
    cd_up_tol (float)
    ad_low_tol (float)
    ad_up_tol (float)
  Returns: bool

bear_bat(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol, ad_low_tol, ad_up_tol)
  bearish bat harmonic pattern condition
  Parameters:
    ab_low_tol (float)
    ab_up_tol (float)
    bc_low_tol (float)
    bc_up_tol (float)
    cd_low_tol (float)
    cd_up_tol (float)
    ad_low_tol (float)
    ad_up_tol (float)
  Returns: bool

bull_bat(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol, ad_low_tol, ad_up_tol)
  bullish bat harmonic pattern condition
  Parameters:
    ab_low_tol (float)
    ab_up_tol (float)
    bc_low_tol (float)
    bc_up_tol (float)
    cd_low_tol (float)
    cd_up_tol (float)
    ad_low_tol (float)
    ad_up_tol (float)
  Returns: bool

bear_butterfly(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol, ad_low_tol, ad_up_tol)
  bearish butterfly harmonic pattern condition
  Parameters:
    ab_low_tol (float)
    ab_up_tol (float)
    bc_low_tol (float)
    bc_up_tol (float)
    cd_low_tol (float)
    cd_up_tol (float)
    ad_low_tol (float)
    ad_up_tol (float)
  Returns: bool

bull_butterfly(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol, ad_low_tol, ad_up_tol)
  bullish butterfly harmonic pattern condition
  Parameters:
    ab_low_tol (float)
    ab_up_tol (float)
    bc_low_tol (float)
    bc_up_tol (float)
    cd_low_tol (float)
    cd_up_tol (float)
    ad_low_tol (float)
    ad_up_tol (float)
  Returns: bool

bear_cassiopeia_a(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol)
  bearish cassiopeia a harmonic pattern condition
  Parameters:
    ab_low_tol (float)
    ab_up_tol (float)
    bc_low_tol (float)
    bc_up_tol (float)
    cd_low_tol (float)
    cd_up_tol (float)
  Returns: bool

bull_cassiopeia_a(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol)
  bullish cassiopeia a harmonic pattern condition
  Parameters:
    ab_low_tol (float)
    ab_up_tol (float)
    bc_low_tol (float)
    bc_up_tol (float)
    cd_low_tol (float)
    cd_up_tol (float)
  Returns: bool

bear_cassiopeia_b(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol)
  bearish cassiopeia b harmonic pattern condition
  Parameters:
    ab_low_tol (float)
    ab_up_tol (float)
    bc_low_tol (float)
    bc_up_tol (float)
    cd_low_tol (float)
    cd_up_tol (float)
  Returns: bool

bull_cassiopeia_b(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol)
  bullish cassiopeia b harmonic pattern condition
  Parameters:
    ab_low_tol (float)
    ab_up_tol (float)
    bc_low_tol (float)
    bc_up_tol (float)
    cd_low_tol (float)
    cd_up_tol (float)
  Returns: bool

bear_cassiopeia_c(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol)
  bearish cassiopeia c harmonic pattern condition
  Parameters:
    ab_low_tol (float)
    ab_up_tol (float)
    bc_low_tol (float)
    bc_up_tol (float)
    cd_low_tol (float)
    cd_up_tol (float)
  Returns: bool

bull_cassiopeia_c(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol)
  bullish cassiopeia c harmonic pattern condition
  Parameters:
    ab_low_tol (float)
    ab_up_tol (float)
    bc_low_tol (float)
    bc_up_tol (float)
    cd_low_tol (float)
    cd_up_tol (float)
  Returns: bool

bear_crab(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol, ad_low_tol, ad_up_tol)
  bearish crab harmonic pattern condition
  Parameters:
    ab_low_tol (float)
    ab_up_tol (float)
    bc_low_tol (float)
    bc_up_tol (float)
    cd_low_tol (float)
    cd_up_tol (float)
    ad_low_tol (float)
    ad_up_tol (float)
  Returns: bool

bull_crab(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol, ad_low_tol, ad_up_tol)
  bullish crab harmonic pattern condition
  Parameters:
    ab_low_tol (float)
    ab_up_tol (float)
    bc_low_tol (float)
    bc_up_tol (float)
    cd_low_tol (float)
    cd_up_tol (float)
    ad_low_tol (float)
    ad_up_tol (float)
  Returns: bool

bear_deep_crab(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol, ad_low_tol, ad_up_tol)
  bearish deep crab harmonic pattern condition
  Parameters:
    ab_low_tol (float)
    ab_up_tol (float)
    bc_low_tol (float)
    bc_up_tol (float)
    cd_low_tol (float)
    cd_up_tol (float)
    ad_low_tol (float)
    ad_up_tol (float)
  Returns: bool

bull_deep_crab(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol, ad_low_tol, ad_up_tol)
  bullish deep crab harmonic pattern condition
  Parameters:
    ab_low_tol (float)
    ab_up_tol (float)
    bc_low_tol (float)
    bc_up_tol (float)
    cd_low_tol (float)
    cd_up_tol (float)
    ad_low_tol (float)
    ad_up_tol (float)
  Returns: bool

bear_cypher(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol, xc_low_tol, xc_up_tol)
  bearish cypher harmonic pattern condition
  Parameters:
    ab_low_tol (float)
    ab_up_tol (float)
    bc_low_tol (float)
    bc_up_tol (float)
    cd_low_tol (float)
    cd_up_tol (float)
    xc_low_tol (float)
    xc_up_tol (float)
  Returns: bool

bull_cypher(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol, xc_low_tol, xc_up_tol)
  bullish cypher harmonic pattern condition
  Parameters:
    ab_low_tol (float)
    ab_up_tol (float)
    bc_low_tol (float)
    bc_up_tol (float)
    cd_low_tol (float)
    cd_up_tol (float)
    xc_low_tol (float)
    xc_up_tol (float)
  Returns: bool

bear_gartley(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol, ad_low_tol, ad_up_tol)
  bearish gartley harmonic pattern condition
  Parameters:
    ab_low_tol (float)
    ab_up_tol (float)
    bc_low_tol (float)
    bc_up_tol (float)
    cd_low_tol (float)
    cd_up_tol (float)
    ad_low_tol (float)
    ad_up_tol (float)
  Returns: bool

bull_gartley(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, cd_low_tol, cd_up_tol, ad_low_tol, ad_up_tol)
  bullish gartley harmonic pattern condition
  Parameters:
    ab_low_tol (float)
    ab_up_tol (float)
    bc_low_tol (float)
    bc_up_tol (float)
    cd_low_tol (float)
    cd_up_tol (float)
    ad_low_tol (float)
    ad_up_tol (float)
  Returns: bool

bear_shark(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, xc_low_tol, xc_up_tol)
  bearish shark harmonic pattern condition
  Parameters:
    ab_low_tol (float)
    ab_up_tol (float)
    bc_low_tol (float)
    bc_up_tol (float)
    xc_low_tol (float)
    xc_up_tol (float)
  Returns: bool

bull_shark(ab_low_tol, ab_up_tol, bc_low_tol, bc_up_tol, xc_low_tol, xc_up_tol)
  bullish shark harmonic pattern condition
  Parameters:
    ab_low_tol (float)
    ab_up_tol (float)
    bc_low_tol (float)
    bc_up_tol (float)
    xc_low_tol (float)
    xc_up_tol (float)
  Returns: bool

bear_three_drive(x1_low_tol, a1_low_tol, a1_up_tol, a2_low_tol, a2_up_tol, b2_low_tol, b2_up_tol, b3_low_tol, b3_upt_tol)
  bearish three drive harmonic pattern condition
  Parameters:
    x1_low_tol (float)
    a1_low_tol (float)
    a1_up_tol (float)
    a2_low_tol (float)
    a2_up_tol (float)
    b2_low_tol (float)
    b2_up_tol (float)
    b3_low_tol (float)
    b3_upt_tol (float)
  Returns: bool

bull_three_drive(x1_low_tol, a1_low_tol, a1_up_tol, a2_low_tol, a2_up_tol, b2_low_tol, b2_up_tol, b3_low_tol, b3_upt_tol)
  bullish three drive harmonic pattern condition
  Parameters:
    x1_low_tol (float)
    a1_low_tol (float)
    a1_up_tol (float)
    a2_low_tol (float)
    a2_up_tol (float)
    b2_low_tol (float)
    b2_up_tol (float)
    b3_low_tol (float)
    b3_upt_tol (float)
  Returns: bool

asc_broadening()
  ascending broadening pattern condition
  Returns: bool

broadening()
  broadening pattern condition
  Returns: bool

desc_broadening()
  descending broadening pattern condition
  Returns: bool

double_bot(low_tol, up_tol)
  double bottom pattern condition
  Parameters:
    low_tol (float)
    up_tol (float)
  Returns: bool

double_top(low_tol, up_tol)
  double top pattern condition
  Parameters:
    low_tol (float)
    up_tol (float)
  Returns: bool

triple_bot(low_tol, up_tol)
  triple bottom pattern condition
  Parameters:
    low_tol (float)
    up_tol (float)
  Returns: bool

triple_top(low_tol, up_tol)
  triple top pattern condition
  Parameters:
    low_tol (float)
    up_tol (float)
  Returns: bool

bear_elliot()
  bearish elliot wave pattern condition
  Returns: bool

bull_elliot()
  bullish elliot wave pattern condition
  Returns: bool

bear_alt_flag(ab_ratio, bc_ratio)
  bearish alternate flag pattern condition
  Parameters:
    ab_ratio (float)
    bc_ratio (float)
  Returns: bool

bull_alt_flag(ab_ratio, bc_ratio)
  bullish alternate flag pattern condition
  Parameters:
    ab_ratio (float)
    bc_ratio (float)
  Returns: bool

bear_flag(ab_ratio, bc_ratio, be_ratio)
  bearish flag pattern condition
  Parameters:
    ab_ratio (float)
    bc_ratio (float)
    be_ratio (float)
  Returns: bool

bull_flag(ab_ratio, bc_ratio, be_ratio)
  bullish flag pattern condition
  Parameters:
    ab_ratio (float)
    bc_ratio (float)
    be_ratio (float)
  Returns: bool

bear_asc_head_shoulders()
  bearish ascending head and shoulders pattern condition
  Returns: bool

bull_asc_head_shoulders()
  bullish ascending head and shoulders pattern condition
  Returns: bool

bear_desc_head_shoulders()
  bearish descending head and shoulders pattern condition
  Returns: bool

bull_desc_head_shoulders()
  bullish descending head and shoulders pattern condition
  Returns: bool

bear_head_shoulders()
  bearish head and shoulders pattern condition
  Returns: bool

bull_head_shoulders()
  bullish head and shoulders pattern condition
  Returns: bool

bear_pennant(ab_ratio, bc_ratio)
  bearish pennant pattern condition
  Parameters:
    ab_ratio (float)
    bc_ratio (float)
  Returns: bool

bull_pennant(ab_ratio, bc_ratio)
  bullish pennant pattern condition
  Parameters:
    ab_ratio (float)
    bc_ratio (float)
  Returns: bool

asc_wedge()
  ascending wedge pattern condition
  Returns: bool

desc_wedge()
  descending wedge pattern condition
  Returns: bool

wedge()
  wedge pattern condition
  Returns: bool
Release Notes
v2: corrected an error in my logic that resulted in some patterns having a lower frequency of occurrence.
statisticsstrategiestechindicator

Pine library

In true TradingView spirit, the author has published this Pine code as an open-source library so that other Pine programmers from our community can reuse it. Cheers to the author! You may use this library privately or in other open-source publications, but reuse of this code in a publication is governed by House rules.

Disclaimer