PINE LIBRARY

TA

53
Library "TA"
General technical analysis functions

div_bull(pS, iS, cp_length_after, cp_length_before, pivot_length, lookback, lookback_pivs, no_broken, pW, iW, hidW, regW)
  Test for bullish divergence
  Parameters:
    pS (float): Price series (float)
    iS (float): Indicator series (float)
    cp_length_after (simple int): Bars after current (divergent) pivot low to be considered a valid pivot (optional int)
    cp_length_before (simple int): Bars before current (divergent) pivot low to be considered a valid pivot (optional int)
    pivot_length (simple int): Bars before and after prior pivot low to be considered valid pivot (optional int)
    lookback (simple int): Bars back to search for prior pivot low (optional int)
    lookback_pivs (simple int): Pivots back to search for prior pivot low (optional int)
    no_broken (simple bool): Flag to only consider divergence valid if the pivot-to-pivot trendline is unbroken (optional bool)
    pW (simple float): Weight of change in price, used in degree of divergence calculation (optional float)
    iW (simple float): Weight of change in indicator, used in degree of divergence calculation (optional float)
    hidW (simple float): Weight of hidden divergence, used in degree of divergence calculation (optional float)
    regW (simple float): Weight of regular divergence, used in degree of divergence calculation (optional float)

  Returns: [flag,degree,type,lx1,ly1,lx2,ly2]
flag = true if divergence exists (bool)
degree = degree (strength) of divergence (float)
type = 1 = regular, 2 = hidden (int)
lx1 = x coordinate 1 (int)
ly1 = y coordinate 1 (float)
lx2 = x coordinate 2 (int)
ly2 = y coordinate 2 (float)

div_bear(pS, iS, cp_length_after, cp_length_before, pivot_length, lookback, lookback_pivs, no_broken, pW, iW, hidW, regW)
  Test for bearish divergence
  Parameters:
    pS (float): Price series (float)
    iS (float): Indicator series (float)
    cp_length_after (simple int): Bars after current (divergent) pivot high to be considered a valid pivot (optional int)
    cp_length_before (simple int): Bars before current (divergent) pivot highto be considered a valid pivot (optional int)
    pivot_length (simple int): Bars before and after prior pivot high to be considered valid pivot (optional int)
    lookback (simple int): Bars back to search for prior pivot high (optional int)
    lookback_pivs (simple int): Pivots back to search for prior pivot high (optional int)
    no_broken (simple bool): Flag to only consider divergence valid if the pivot-to-pivot trendline is unbroken (optional bool)
    pW (simple float): Weight of change in price, used in degree of divergence calculation (optional float)
    iW (simple float): Weight of change in indicator, used in degree of divergence calculation (optional float)
    hidW (simple float): Weight of hidden divergence, used in degree of divergence calculation (optional float)
    regW (simple float): Weight of regular divergence, used in degree of divergence calculation (optional float)

  Returns: [flag,degree,type,lx1,ly1,lx2,ly2]
flag = true if divergence exists (bool)
degree = degree (strength) of divergence (float)
type = 1 = regular, 2 = hidden (int)
lx1 = x coordinate 1 (int)
ly1 = y coordinate 1 (float)
lx2 = x coordinate 2 (int)
ly2 = y coordinate 2 (float)

test_cd(cd, bc, xa, xc, ad, pErr, p_types)
  Validate CD leg of XABCD
  Parameters:
    cd (float)
    bc (float)
    xa (float)
    xc (float)
    ad (float)
    pErr (float)
    p_types (array<bool>)

pat_xabcd_testSym(xax, abx, bcx, cdx, pAsym)
  Validate ΔX symmetry of XABCD pattern
  Parameters:
    xax (int)
    abx (int)
    bcx (int)
    cdx (int)
    pAsym (float)

harmonic_xabcd_validate(xX, xY, aX, aY, bX, bY, cX, cY, dX, dY, pErr, pAsym, gart, bat, bfly, crab, shark, cyph)
  Validate harmonic XABCD pattern
  Parameters:
    xX (int): X coordinate of point X (int)
    xY (float): Y coordinate of point X (float)
    aX (int): X coordinate of point A (int)
    aY (float): Y coordinate of point A (float)
    bX (int): X coordinate of point B (int)
    bY (float): Y coordinate of point B (float)
    cX (int): X coordinate of point C (int)
    cY (float): Y coordinate of point C (float)
    dX (int): X coordinate of point D (int)
    dY (float): Y coordinate of point D (float)
    pErr (float): Acceptable percent error of leg ratios (does not apply to legs defined within a range) (float)
    pAsym (float): Acceptable percent asymmetry of leg ΔX (each leg tested against average ΔX of prior legs) (float)
    gart (bool): Flag to validate Gartley pattern (bool)
    bat (bool): Flag to validate Bat pattern (bool)
    bfly (bool): Flag to validate Butterfly pattern (bool)
    crab (bool): Flag to validate Crab pattern (bool)
    shark (bool): Flag to validate Shark pattern (bool)
    cyph (bool): Flag to validate Cypher pattern (bool)

  Returns: [flag,t1,t2,t3,t4,t5,t6]
flag = true if valid harmonic
t1 = true if valid gartley
t2 = true if valid bat
t3 = true if valid butterfly
t4 = true if valid crab
t5 = true if valid shark
t6 = true if valid cypher

harmonic_xabcd_validateIncomplete(xX, xY, aX, aY, bX, bY, cX, cY, pErr, pAsym, gart, bat, bfly, crab, shark, cyph)
  Validate the first 3 legs of a harmonic XABCD pattern
  Parameters:
    xX (int): X coordinate of point X (int)
    xY (float): Y coordinate of point X (float)
    aX (int): X coordinate of point A (int)
    aY (float): Y coordinate of point A (float)
    bX (int): X coordinate of point B (int)
    bY (float): Y coordinate of point B (float)
    cX (int): X coordinate of point C (int)
    cY (float): Y coordinate of point C (float)
    pErr (float): Acceptable percent error of leg ratios (does not apply to legs defined within a range) (float)
    pAsym (float): Acceptable percent asymmetry of leg ΔX (each leg tested against average ΔX of prior legs) (float)
    gart (bool): Flag to validate Gartley pattern (bool)
    bat (bool): Flag to validate Bat pattern (bool)
    bfly (bool): Flag to validate Butterfly pattern (bool)
    crab (bool): Flag to validate Crab pattern (bool)
    shark (bool): Flag to validate Shark pattern (bool)
    cyph (bool): Flag to validate Cypher pattern (bool)

  Returns: [flag,t1,t2,t3,t4]
flag = true if valid harmonic
t1 = true if valid gartley
t2 = true if valid bat
t3 = true if valid butterfly
t4 = true if valid crab
t5 = true if valid shark
t6 = true if valid cypher

harmonic_xabcd_prz(type, xY, aY, bY, cY)
  Get the potential reversal zone (PRZ) levels of a harmonic XABCD pattern
  Parameters:
    type (int): Harmonic pattern type (int - 1 = Gartley, 2 = Bat, 3 = Butterfly, 4 = Crab, 5 = Shark, 6 = Cypher)
    xY (float): Y coordinate of point X (float)
    aY (float): Y coordinate of point A (float)
    bY (float): Y coordinate of point B (float)
    cY (float): Y coordinate of point C (float)

  Returns: [bc_u, bc_l, xa_u, xa_l]
bc_u = nearest BC retracement/extension level (nearest to point C)
bc_l = farthest BC retracement/extension level (nearest to point C)
xa_u = nearest XA retracement/extension level (or the only XA level, if applicable)
xa_l = farthest XA retracement/extension level (or na if not applicable)

harmonic_xabcd_przClosest(l1, l2, l3, l4)
  Get the confluent PRZ levels (i.e. the two closest PRZ levels)

Order of arguments does not matter
  Parameters:
    l1 (float): level 1 (float)
    l2 (float): level 2 (float)
    l3 (float): level 3 (float)
    l4 (float): level 4 (optional, float)

  Returns: [lL,lH]
lL = lower confluent PRZ level
lH = higher confluent PRZ level

harmonic_xabcd_przRange(l1, l2, l3, l4)
  Get upper and lower PRZ levels
  Parameters:
    l1 (float)
    l2 (float)
    l3 (float)
    l4 (float)

harmonic_xabcd_eD(cpl1, cpl2, xY, aY, dY)
  Measure closeness of D to either of the two closest PRZ levels, relative to height of the XA leg
  Parameters:
    cpl1 (float)
    cpl2 (float)
    xY (float)
    aY (float)
    dY (float)

harmonic_xabcd_przScore(xY, aY, l1, l2, l3, l4)
  Measure the closeness of the two closest PRZ levels, relative to the height of the XA leg
  Parameters:
    xY (float)
    aY (float)
    l1 (float)
    l2 (float)
    l3 (float)
    l4 (float)

harmonic_xabcd_rAndE(type, l, l1, l2)
  Get the ratio of two pattern legs, and the percent error from the theoretical harmonic ratio

Order of arguments does not matter
  Parameters:
    type (int): Harmonic pattern type (int - 1 = Gartley, 2 = Bat, 3 = Butterfly, 4 = Crab)
    l (string): Leg ID ("xab", "abc", "bcd", or "xad") (string)
    l1 (float): Line 1 height (float)
    l2 (float): Line 2 height (float)

  Returns: [r,e]

harmonic_xabcd_eAvg(xbre, acre, bdre, xdre, xcdre)
  Get the avg retracement ratio % error
  Parameters:
    xbre (float)
    acre (float)
    bdre (float)
    xdre (float)
    xcdre (float)

pat_xabcd_asym(xX, aX, bX, cX, dX)
  Get the avg asymmetry %
  Parameters:
    xX (int)
    aX (int)
    bX (int)
    cX (int)
    dX (int)

harmonic_xabcd_entry(t, tp, xY, aY, bY, cY, dY, e_afterC, e_lvlc, e_afterD, e_lvldPct)
  Get potential entry levels for a harmonic XABCD pattern
  Parameters:
    t (bool)
    tp (int)
    xY (float)
    aY (float)
    bY (float)
    cY (float)
    dY (float)
    e_afterC (bool)
    e_lvlc (string)
    e_afterD (bool)
    e_lvldPct (float)

xabcd_entryHit(t, afterC, afterD, dX, e_afterC, e_afterD, dValBars)
  Determine if entry level was reached. Assumes pattern is active/not timed out.
  Parameters:
    t (bool)
    afterC (float)
    afterD (float)
    dX (int)
    e_afterC (bool)
    e_afterD (bool)
    dValBars (int)

pat_xabcd_validate(xX, xY, aX, aY, bX, bY, cX, cY, dX, dY, xab, abc, bcd, xad, xcd, pErr, pAsym)
  Validate custom XABCD pattern
  Parameters:
    xX (int): X coordinate of point X (int)
    xY (float): Y coordinate of point X (float)
    aX (int): X coordinate of point A (int)
    aY (float): Y coordinate of point A (float)
    bX (int): X coordinate of point B (int)
    bY (float): Y coordinate of point B (float)
    cX (int): X coordinate of point C (int)
    cY (float): Y coordinate of point C (float)
    dX (int): X coordinate of point D (int)
    dY (float): Y coordinate of point D (float)
    xab (float)
    abc (float)
    bcd (float)
    xad (float)
    xcd (float)
    pErr (float): Acceptable percent error of leg ratios (does not apply to legs defined within a range) (float)
    pAsym (float): Acceptable percent asymmetry of leg ΔX (each leg tested against average ΔX of prior legs) (float)

  Returns: TRUE if pattern is valid

pat_xabcd_validateIncomplete(xX, xY, aX, aY, bX, bY, cX, cY, xab, abc, pErr, pAsym)
  Validate the first 3 legs of a custom XABCD pattern
  Parameters:
    xX (int): X coordinate of point X (int)
    xY (float): Y coordinate of point X (float)
    aX (int): X coordinate of point A (int)
    aY (float): Y coordinate of point A (float)
    bX (int): X coordinate of point B (int)
    bY (float): Y coordinate of point B (float)
    cX (int): X coordinate of point C (int)
    cY (float): Y coordinate of point C (float)
    xab (float)
    abc (float)
    pErr (float): Acceptable percent error of leg ratios (does not apply to legs defined within a range) (float)
    pAsym (float): Acceptable percent asymmetry of leg ΔX (each leg tested against average ΔX of prior legs) (float)

  Returns: TRUE if first 3 legs are valid

pat_xabcd_prz(xY, aY, bY, cY, xad, bcd, xcd)
  Get the potential reversal zone (PRZ) levels of a custom XABCD pattern
  Parameters:
    xY (float): Y coordinate of point X (float)
    aY (float): Y coordinate of point A (float)
    bY (float): Y coordinate of point B (float)
    cY (float): Y coordinate of point C (float)

    xad (float)
    bcd (float)
    xcd (float)
  Returns: [xad_lvl,bcd_lvl,xcd_lvl]

pat_xabcd_avgDev(xX, xY, aX, aY, bX, bY, cX, cY, dX, dY)
  Get the average deviation of an XABCD pattern
  Parameters:
    xX (int)
    xY (float)
    aX (int)
    aY (float)
    bX (int)
    bY (float)
    cX (int)
    cY (float)
    dX (int)
    dY (float)

harmonic_xabcd_score(tp, xX, xY, aX, aY, bX, bY, cX, cY, dX, dY)
  Get score values for a pattern
  Parameters:
    tp (int)
    xX (int)
    xY (float)
    aX (int)
    aY (float)
    bX (int)
    bY (float)
    cX (int)
    cY (float)
    dX (int)
    dY (float)

harmonic_xabcd_scoreTot(asym, eavg, przscore, eD, tp, w_a, w_e, w_p, w_d)
  Get total weighted score value for a pattern
  Parameters:
    asym (float)
    eavg (float)
    przscore (float)
    eD (float)
    tp (int)
    w_a (float)
    w_e (float)
    w_p (float)
    w_d (float)

harmonic_xabcd_targets(xY, aY, bY, cY, dY, tgt1, tgt2, tgt3)
  Get target level
  Parameters:
    xY (float)
    aY (float)
    bY (float)
    cY (float)
    dY (float)
    tgt1 (string)
    tgt2 (string)
    tgt3 (string)

harmonic_xabcd_stop(stop, stopPct, bull, xY, dY, upper, lower, t1, eY)
  Get stop level
  Parameters:
    stop (string)
    stopPct (float)
    bull (bool)
    xY (float)
    dY (float)
    upper (float)
    lower (float)
    t1 (float)
    eY (float)

harmonic_xabcd_fibDispTxt(tp)
  Get fib ratio display text
  Parameters:
    tp (int)

harmonic_xabcd_symbol(tp)
  Get pattern symbol
  Parameters:
    tp (int)

pat_xabcd(x_is_low, pivot_length, source, conf_length, incomplete)
  Determine if an XABCD pattern has just completed (i.e. point D is on the previous bar)
  Parameters:
    x_is_low (bool): Flag to determine if point X is a low pivot, i.e. bullish pattern (bool, dft = true)
    pivot_length (int): Number of bars before and after a valid pivot (int, dft = 5)
    source (float): Source series (float, dft = na, will use high and low series)
    conf_length (int): Number of trailing bars after pivot point D to confirm a valid pattern (int, dft = 1)
    incomplete (bool): Flag to return an incomplete XABC pattern (bool, dft = false)
  Returns: [flag,xx,xy,ax,ay,bx,by,cx,cy,dx,dy]
flag = true if valid XABCD pattern completed on previous bar
xx = X coordinate of point X (int)
xy = Y coordinate of point X (float)
ax = X coordinate of point A (int)
ay = Y coordinate of point A (float)
bx = X coordinate of point B (int)
by = Y coordinate of point B (float)
cx = X coordinate of point C (int)
cy = Y coordinate of point C (float)
dx = X coordinate of point D (int)
dy = Y coordinate of point D (float)

pat_xabcdIncomplete(x_is_low, pivot_length, source, conf_length)
  Determine if an XABCD pattern is in progress (point C was just confirmed)
  Parameters:
    x_is_low (bool): Flag to determine if point X is a low pivot, i.e. bullish M pattern (bool, dft = true)
    pivot_length (int): Number of bars before and after a valid pivot (int, dft = 5)
    source (float): Source series (float, dft = na, will use high and low series)
    conf_length (int): Number of trailing bars after pivot point D to confirm a valid pattern (int, dft = 1)
  Returns: [flag,xx,xy,ax,ay,bx,by,cx,cy]
flag = true if valid XABC pattern completed on bar_index[conf_length]
xx = X coordinate of point X (int)
xy = Y coordinate of point X (float)
ax = X coordinate of point A (int)
ay = Y coordinate of point A (float)
bx = X coordinate of point B (int)
by = Y coordinate of point B (float)
cx = X coordinate of point C (int)
cy = Y coordinate of point C (float)
dx = X coordinate of point D (int)
dy = Y coordinate of point D (float)

success(eX, stop, t1, t2)
  Determine if trade is successful
  Parameters:
    eX (int): Entry bar index (int)
    stop (float): Stop level (float)
    t1 (float): Target 1 level (float)
    t2 (float): Target 2 level (float)

  Returns: [t1Hit,t2Hit,t1x,t1y,t2x,t2y]

tradeClosed(eX, eY, stop, t1h, t2h, t1, t2)
  Determine if Target or Stop was hit on the current bar
  Parameters:
    eX (int)
    eY (float)
    stop (float)
    t1h (bool)
    t2h (bool)
    t1 (float)
    t2 (float)

Wyłączenie odpowiedzialności

Informacje i publikacje przygotowane przez TradingView lub jego użytkowników, prezentowane na tej stronie, nie stanowią rekomendacji ani porad handlowych, inwestycyjnych i finansowych i nie powinny być w ten sposób traktowane ani wykorzystywane. Więcej informacji na ten temat znajdziesz w naszym Regulaminie.