div_bull(pS, iS, cp_length_after, cp_length_before, pivot_length, lookback, no_broken, pW, iW, hidW, regW) ββTest for bullish divergence ββParameters: ββββpS: Price series (float) ββββiS: Indicator series (float) ββββcp_length_after: Bars after current (divergent) pivot low to be considered a valid pivot (optional int) ββββcp_length_before: Bars before current (divergent) pivot low to be considered a valid pivot (optional int) ββββpivot_length: Bars before and after prior pivot low to be considered valid pivot (optional int) ββββlookback: Bars back to search for prior pivot low (optional int) ββββno_broken: Flag to only consider divergence valid if the pivot-to-pivot trendline is unbroken (optional bool) ββββpW: Weight of change in price, used in degree of divergence calculation (optional float) ββββiW: Weight of change in indicator, used in degree of divergence calculation (optional float) ββββhidW: Weight of hidden divergence, used in degree of divergence calculation (optional float) ββββregW: 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, no_broken, pW, iW, hidW, regW) ββTest for bearish divergence ββParameters: ββββpS: Price series (float) ββββiS: Indicator series (float) ββββcp_length_after: Bars after current (divergent) pivot high to be considered a valid pivot (optional int) ββββcp_length_before: Bars before current (divergent) pivot highto be considered a valid pivot (optional int) ββββpivot_length: Bars before and after prior pivot high to be considered valid pivot (optional int) ββββlookback: Bars back to search for prior pivot high (optional int) ββββno_broken: Flag to only consider divergence valid if the pivot-to-pivot trendline is unbroken (optional bool) ββββpW: Weight of change in price, used in degree of divergence calculation (optional float) ββββiW: Weight of change in indicator, used in degree of divergence calculation (optional float) ββββhidW: Weight of hidden divergence, used in degree of divergence calculation (optional float) ββββregW: 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)
Notes de version
β
v2 Return absolute value of degree to handle series with negative values.
Notes de version
β
v3 - Added support for lookback # of pivots for div_bull() and div_bear() - Fixed divergence degree calculation when indicator series has negative values - Changed default pivot lengths for div_bull() and div_bear()
Updated: 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: Price series (float) ββββiS: Indicator series (float) ββββcp_length_after: Bars after current (divergent) pivot low to be considered a valid pivot (optional int) ββββcp_length_before: Bars before current (divergent) pivot low to be considered a valid pivot (optional int) ββββpivot_length: Bars before and after prior pivot low to be considered valid pivot (optional int) ββββlookback: Bars back to search for prior pivot low (optional int) ββββlookback_pivs: Pivots back to search for prior pivot low (optional int) ββββno_broken: Flag to only consider divergence valid if the pivot-to-pivot trendline is unbroken (optional bool) ββββpW: Weight of change in price, used in degree of divergence calculation (optional float) ββββiW: Weight of change in indicator, used in degree of divergence calculation (optional float) ββββhidW: Weight of hidden divergence, used in degree of divergence calculation (optional float) ββββregW: 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: Price series (float) ββββiS: Indicator series (float) ββββcp_length_after: Bars after current (divergent) pivot high to be considered a valid pivot (optional int) ββββcp_length_before: Bars before current (divergent) pivot highto be considered a valid pivot (optional int) ββββpivot_length: Bars before and after prior pivot high to be considered valid pivot (optional int) ββββlookback: Bars back to search for prior pivot high (optional int) ββββlookback_pivs: Pivots back to search for prior pivot high (optional int) ββββno_broken: Flag to only consider divergence valid if the pivot-to-pivot trendline is unbroken (optional bool) ββββpW: Weight of change in price, used in degree of divergence calculation (optional float) ββββiW: Weight of change in indicator, used in degree of divergence calculation (optional float) ββββhidW: Weight of hidden divergence, used in degree of divergence calculation (optional float) ββββregW: 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)
Notes de version
β
v4 Changed divergence strength/degree calculation to use the angle of the divergence line divided by 90 degrees (as opposed to the % change in the indicator value). This will keep the unweighted strength value between 0 and 1 for the indicator portion of the calculation, which is desirable because different indicator series can have wildly different ranges.
Notes de version
β
v5 Added chk_prev_bar flag as an argument to the divergence checks, which will check for divergence using the indicator value from the prior bar. This is necessary in some cases where the indicator is using a different price source than the one passed into the divergence function.
Updated: div_bull(pS, iS, chk_prev_bar, cp_length_after, cp_length_before, pivot_length, lookback, lookback_pivs, no_broken, pW, iW, hidW, regW) ββTest for bullish divergence ββParameters: ββββpS: Price series (float) ββββiS: Indicator series (float) ββββchk_prev_bar: Flag to check for divergence using the indicator value from the prior bar. This is necessary in some cases where the indicator is using a different price source than the one passed in pS. ββββcp_length_after: Bars after current (divergent) pivot low to be considered a valid pivot (optional int) ββββcp_length_before: Bars before current (divergent) pivot low to be considered a valid pivot (optional int) ββββpivot_length: Bars before and after prior pivot low to be considered valid pivot (optional int) ββββlookback: Bars back to search for prior pivot low (optional int) ββββlookback_pivs: Pivots back to search for prior pivot low (optional int) ββββno_broken: Flag to only consider divergence valid if the pivot-to-pivot trendline is unbroken (optional bool) ββββpW: Weight of change in price, used in degree of divergence calculation (optional float) ββββiW: Weight of change in indicator, used in degree of divergence calculation (optional float) ββββhidW: Weight of hidden divergence, used in degree of divergence calculation (optional float) ββββregW: 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, chk_prev_bar, cp_length_after, cp_length_before, pivot_length, lookback, lookback_pivs, no_broken, pW, iW, hidW, regW) ββTest for bearish divergence ββParameters: ββββpS: Price series (float) ββββiS: Indicator series (float) ββββchk_prev_bar: Flag to check for divergence using the indicator value from the prior bar. This is necessary in some cases where the indicator is using a different price source than the one passed in pS. ββββcp_length_after: Bars after current (divergent) pivot high to be considered a valid pivot (optional int) ββββcp_length_before: Bars before current (divergent) pivot highto be considered a valid pivot (optional int) ββββpivot_length: Bars before and after prior pivot high to be considered valid pivot (optional int) ββββlookback: Bars back to search for prior pivot high (optional int) ββββlookback_pivs: Pivots back to search for prior pivot high (optional int) ββββno_broken: Flag to only consider divergence valid if the pivot-to-pivot trendline is unbroken (optional bool) ββββpW: Weight of change in price, used in degree of divergence calculation (optional float) ββββiW: Weight of change in indicator, used in degree of divergence calculation (optional float) ββββhidW: Weight of hidden divergence, used in degree of divergence calculation (optional float) ββββregW: 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)
Notes de version
β
v6 When calculating the divergence strength on an indicator, Scale the X coordinates to a range similar to the Y scale (X and Y scales should be on the same order of magnitude for the angle value to be meaningful. e.g. if ΞY is 10,000,000 and ΞX is 12, the angle will always be very nearly 90 degrees, which makes for a meaningless value)
Notes de version
β
v7 Adjusted multiplier in iDelta() to use the average Y value rather than the difference of the two Y values.
Notes de version
β
v8 Now calculating divergence strength in terms of the standard deviation. = Ξ price/StDev + Ξ indicator/stDev (multiplied by specified weights)
Notes de version
β
v9
Notes de version
β
v10 Changes to check more thoroughly for pivots on indicator series.
Updated: 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: Price series (float) ββββiS: Indicator series (float) ββββcp_length_after: Bars after current (divergent) pivot low to be considered a valid pivot (optional int) ββββcp_length_before: Bars before current (divergent) pivot low to be considered a valid pivot (optional int) ββββpivot_length: Bars before and after prior pivot low to be considered valid pivot (optional int) ββββlookback: Bars back to search for prior pivot low (optional int) ββββlookback_pivs: Pivots back to search for prior pivot low (optional int) ββββno_broken: Flag to only consider divergence valid if the pivot-to-pivot trendline is unbroken (optional bool) ββββpW: Weight of change in price, used in degree of divergence calculation (optional float) ββββiW: Weight of change in indicator, used in degree of divergence calculation (optional float) ββββhidW: Weight of hidden divergence, used in degree of divergence calculation (optional float) ββββregW: 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: Price series (float) ββββiS: Indicator series (float) ββββcp_length_after: Bars after current (divergent) pivot high to be considered a valid pivot (optional int) ββββcp_length_before: Bars before current (divergent) pivot highto be considered a valid pivot (optional int) ββββpivot_length: Bars before and after prior pivot high to be considered valid pivot (optional int) ββββlookback: Bars back to search for prior pivot high (optional int) ββββlookback_pivs: Pivots back to search for prior pivot high (optional int) ββββno_broken: Flag to only consider divergence valid if the pivot-to-pivot trendline is unbroken (optional bool) ββββpW: Weight of change in price, used in degree of divergence calculation (optional float) ββββiW: Weight of change in indicator, used in degree of divergence calculation (optional float) ββββhidW: Weight of hidden divergence, used in degree of divergence calculation (optional float) ββββregW: 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)
Notes de version
β
v11 div_bull() and div_bear() - adjusted indicator pivot checking to be more inclusive.
Notes de version
β
v12 Added function for validating harmonic XABCD patterns: harmonic_validate_xabcd()
Added: harmonic_validate_xabcd(xX, xY, aX, aY, bX, bY, cX, cY, dX, dY, pErr, pAsym, pivot_length, gart, bat, bfly, crab) ββValidate harmonic XABCD pattern ββParameters: ββββ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) ββββpErr: Acceptable percent error of leg ratios (does not apply to legs defined within a range) (float) ββββpAsym: Acceptable percent asymmetry of leg ΞX (each leg tested against average ΞX of prior legs) (float) ββββpivot_length: Bars before and after prior pivot high to be considered valid pivot (optional int) ββββgart: Flag to validate Gartley pattern (bool) ββββbat: Flag to validate Bat pattern (bool) ββββbfly: Flag to validate Butterfly pattern (bool) ββββcrab: Flag to validate Crab 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
Notes de version
β
v13
Added pattern_xabcd() - determine if an XABCD pattern has just completed.
Added: pattern_xabcd(x_is_low, pivot_length, source) ββDetermine if an XABCD pattern has just completed (i.e. point D is on the previous bar) ββParameters: ββββx_is_low: Flag to determine if point X is a low pivot, i.e. bullish pattern (bool, dft = true) ββββpivot_length: Number of bars before and after a valid pivot (int, dft = 5) ββββsource: Source series (float, dft = na, will use high and low series) ββ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)
Notes de version
β
v14
Added: pat_xabcd(x_is_low, pivot_length, source) ββDetermine if an XABCD pattern has just completed (i.e. point D is on the previous bar) ββParameters: ββββx_is_low: Flag to determine if point X is a low pivot, i.e. bullish pattern (bool, dft = true) ββββpivot_length: Number of bars before and after a valid pivot (int, dft = 5) ββββsource: Source series (float, dft = na, will use high and low series) ββ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)
Removed: pattern_xabcd(x_is_low, pivot_length, source) ββDetermine if an XABCD pattern has just completed (i.e. point D is on the previous bar)
Notes de version
β
v15 Fixed point D validation for harmonic XABCD pattern
Notes de version
β
v16 Fixed harmonic XABCD ΞX symmetry validation
Notes de version
β
v17
Added: harmonic_xabcd_validate(xX, xY, aX, aY, bX, bY, cX, cY, dX, dY, pErr, pAsym, pivot_length, gart, bat, bfly, crab) ββValidate harmonic XABCD pattern ββParameters: ββββ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) ββββpErr: Acceptable percent error of leg ratios (does not apply to legs defined within a range) (float) ββββpAsym: Acceptable percent asymmetry of leg ΞX (each leg tested against average ΞX of prior legs) (float) ββββpivot_length: Bars before and after prior pivot high to be considered valid pivot (optional int) ββββgart: Flag to validate Gartley pattern (bool) ββββbat: Flag to validate Bat pattern (bool) ββββbfly: Flag to validate Butterfly pattern (bool) ββββcrab: Flag to validate Crab 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
harmonic_xabcd_prz(type, xY, aY, bY, cY) ββGet the potential reversal zone (PRZ) levels of a harmonic XABCD pattern ββParameters: ββββtype: Harmonic pattern type (int - 1 = Gartley, 2 = Bat, 3 = Butterfly, 4 = Crab) ββββxY: Y coordinate of point X (float) ββββaY: Y coordinate of point A (float) ββββbY: Y coordinate of point B (float) ββββcY: 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)
Added: harmonic_xabcd_validateIncomplete(xX, xY, aX, aY, bX, bY, cX, cY, pErr, pAsym, pivot_length, gart, bat, bfly, crab) ββValidate the first 3 legs of a harmonic XABCD pattern ββParameters: ββββ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) ββββpErr: Acceptable percent error of leg ratios (does not apply to legs defined within a range) (float) ββββpAsym: Acceptable percent asymmetry of leg ΞX (each leg tested against average ΞX of prior legs) (float) ββββpivot_length: Bars before and after prior pivot high to be considered valid pivot (optional int) ββββgart: Flag to validate Gartley pattern (bool) ββββbat: Flag to validate Bat pattern (bool) ββββbfly: Flag to validate Butterfly pattern (bool) ββββcrab: Flag to validate Crab 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
Notes de version
β
v20 Fixed bug with pat_axbcd() algorithm, checking wrong pivot looking for point C in bearish patterns.
Notes de version
β
v21 Fixed bug in pat_xabcd() where intermediate low wasn't being detected between points C and D
Notes de version
β
v22
Added: 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: level 1 (float) ββββl2: level 2 (float) ββββl3: level 3 (float) ββββl4: level 4 (optional, float) ββReturns: [lL,lH] lL = lower confluent PRZ level lH = higher confluent PRZ level
Notes de version
β
v23
Added: success(entry, stop, t1, t2) ββDetermine if trade is successful ββParameters: ββββentry: Entry bar index (int) ββββstop: Stop level (float) ββββt1: Target 1 level (float) ββββt2: Target 2 level (float) ββReturns: [t1Hit,t2Hit,t1x,t1y,t2x,t2y]
Notes de version
β
v24
Added: 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: Harmonic pattern type (int - 1 = Gartley, 2 = Bat, 3 = Butterfly, 4 = Crab) ββββl: Leg ID ("xab", "abc", "bcd", or "xad") (string) ββββl1: Line 1 height (float) ββββl2: Line 2 height (float) ββReturns: [r,e]
Notes de version
β
v25
Added: harmonic_xabcd_przRange() ββGet upper and lower PRZ levels
harmonic_xabcd_eD() ββMeasure closeness of D to either of the two closest PRZ levels, relative to height of the XA leg
przScore() ββMeasure the closeness of the two closest PRZ levels, relative to the height of the XA leg
harmonic_xabcd_eAvg() ββGet the avg retracement ratio % error
harmonic_xabcd_targets() ββGet target level
pat_xabcd_asym() ββGet the avg asymmetry %
Notes de version
β
v26
Added: harmonic_xabcd_przScore() ββMeasure the closeness of the two closest PRZ levels, relative to the height of the XA leg
Removed: przScore() ββMeasure the closeness of the two closest PRZ levels, relative to the height of the XA leg
Notes de version
β
v27
Updated: pat_xabcd(x_is_low, pivot_length, source, conf_length) ββDetermine if an XABCD pattern has just completed (i.e. point D is on the previous bar) ββParameters: ββββx_is_low: Flag to determine if point X is a low pivot, i.e. bullish pattern (bool, dft = true) ββββpivot_length: Number of bars before and after a valid pivot (int, dft = 5) ββββsource: Source series (float, dft = na, will use high and low series) ββββconf_length: 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,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)
Notes de version
β
v28
Notes de version
β
v29
Notes de version
β
v30
Added: harmonic_xabcd_score() ββGet score values for a pattern
Notes de version
β
v31 Added Shark and Cypher XABCD patterns
Updated: harmonic_xabcd_validate(xX, xY, aX, aY, bX, bY, cX, cY, dX, dY, pErr, pAsym, pivot_length, gart, bat, bfly, crab, shark, cyph) ββValidate harmonic XABCD pattern ββParameters: ββββ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) ββββpErr: Acceptable percent error of leg ratios (does not apply to legs defined within a range) (float) ββββpAsym: Acceptable percent asymmetry of leg ΞX (each leg tested against average ΞX of prior legs) (float) ββββpivot_length: Bars before and after prior pivot high to be considered valid pivot (optional int) ββββgart: Flag to validate Gartley pattern (bool) ββββbat: Flag to validate Bat pattern (bool) ββββbfly: Flag to validate Butterfly pattern (bool) ββββcrab: Flag to validate Crab pattern (bool) ββββshark: Flag to validate Shark pattern (bool) ββββcyph: 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, pivot_length, gart, bat, bfly, crab, shark, cyph) ββValidate the first 3 legs of a harmonic XABCD pattern ββParameters: ββββ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) ββββpErr: Acceptable percent error of leg ratios (does not apply to legs defined within a range) (float) ββββpAsym: Acceptable percent asymmetry of leg ΞX (each leg tested against average ΞX of prior legs) (float) ββββpivot_length: Bars before and after prior pivot high to be considered valid pivot (optional int) ββββgart: Flag to validate Gartley pattern (bool) ββββbat: Flag to validate Bat pattern (bool) ββββbfly: Flag to validate Butterfly pattern (bool) ββββcrab: Flag to validate Crab pattern (bool) ββββshark: Flag to validate Shark pattern (bool) ββββcyph: 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
Notes de version
β
v32
Updated: harmonic_xabcd_przScore() ββMeasure the closeness of the two closest PRZ levels, relative to the height of the XA leg
Notes de version
β
v33
Added: harmonic_xabcd_fibDispTxt() ββGet fib ratio display text
Notes de version
β
v34
Added: harmonic_xabcd_symbol() ββGet pattern symbol
Notes de version
β
v35
Added: harmonic_xabcd_scoreTot() ββGet total weighted score value for a pattern
Notes de version
β
v36
Removed: harmonic_xabcd_scoreTot() ββGet total weighted score value for a pattern
harmonic_xabcd_fibDispTxt() ββGet fib ratio display text
harmonic_xabcd_symbol() ββGet pattern symbol
Notes de version
β
v37
Added: harmonic_xabcd_scoreTot() ββGet pattern's total weighted score
Notes de version
β
v38
Added: harmonic_xabcd_fibDispTxt() ββGet fib ratio display text
harmonic_xabcd_symbol() ββGet pattern symbol
Notes de version
β
v39
Notes de version
β
v40
Notes de version
β
v41
Notes de version
β
v42
Added: harmonic_xabcd_stop() ββGet stop level
Notes de version
β
v43 Fixed bug with cypher validation of point D (retracement of XC, not XA)
Notes de version
β
v44
Notes de version
β
v45 Removed redundant "==true" comparisons
Notes de version
β
v46 Fixed bug with cypher PRZ level
Notes de version
β
v47
Added: pat_xabcd_avgDev() ββGet the average % deviation of an XABCD pattern
Notes de version
β
v48
Notes de version
β
v49 Testing
Notes de version
β
v50 Testing
Notes de version
β
v51
Added: pat_xabcd_validate(xX, xY, aX, aY, bX, bY, cX, cY, dX, dY, pErr, pAsym) ββValidate custom XABCD pattern ββParameters: ββββ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) ββββpErr: Acceptable percent error of leg ratios (does not apply to legs defined within a range) (float) ββββpAsym: 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, pErr, pAsym) ββValidate the first 3 legs of a custom XABCD pattern ββParameters: ββββ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) ββββpErr: Acceptable percent error of leg ratios (does not apply to legs defined within a range) (float) ββββpAsym: 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) ββGet the potential reversal zone (PRZ) levels of a custom XABCD pattern ββParameters: ββββxY: Y coordinate of point X (float) ββββaY: Y coordinate of point A (float) ββββbY: Y coordinate of point B (float) ββββcY: Y coordinate of point C (float) ββReturns: [xad_lvl,bcd_lvl,xcd_lvl]
Notes de version
β
v52
Updated: harmonic_xabcd_eAvg() ββGet the avg retracement ratio % error
Notes de version
β
v53 Fixed bug with success(), extra checks on entry bar
Notes de version
β
v54
Added: tradeClosed() ββDetermine if Target or Stop was hit on the current bar
Notes de version
β
v55 Bug fix for closed trade check
Notes de version
β
v56 Bug fix for closed trade check
Notes de version
β
v57
Updated: 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: Flag to determine if point X is a low pivot, i.e. bullish pattern (bool, dft = true) ββββpivot_length: Number of bars before and after a valid pivot (int, dft = 5) ββββsource: Source series (float, dft = na, will use high and low series) ββββconf_length: Number of trailing bars after pivot point D to confirm a valid pattern (int, dft = 1) ββββincomplete: 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)
Notes de version
β
v58 Short circuit incomplete XABCD pattern search
Notes de version
β
v59
Updated: harmonic_xabcd_przRange() ββGet upper and lower PRZ levels
Notes de version
β
v60
Added: harmonic_xabcd_entry()
Notes de version
β
v61
Added: xabcd_entryHit() ββDetermine if entry level was reached. Assumes pattern is active/not timed out.
Notes de version
β
v62 Updated przClosest check to exclude values of 0 (only used when actual retracement value < 0)
Notes de version
β
v63 backed out last change
Notes de version
β
v64 test
Notes de version
β
v65 dont allow entry value < 0
Notes de version
β
v66 Updated to use latest version of Fib script (improved efficiency for precise fibs)
Notes de version
β
v67 test
Updated: 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: Flag to determine if point X is a low pivot, i.e. bullish pattern (bool, dft = true) ββββpivot_length: Number of bars before and after a valid pivot (int, dft = 5) ββββsource: Source series (float, dft = na, will use high and low series) ββββconf_length: Number of trailing bars after pivot point D to confirm a valid pattern (int, dft = 1) ββββincomplete: 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)
Notes de version
β
v68 Reverted test changes
Updated: 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: Flag to determine if point X is a low pivot, i.e. bullish pattern (bool, dft = true) ββββpivot_length: Number of bars before and after a valid pivot (int, dft = 5) ββββsource: Source series (float, dft = na, will use high and low series) ββββconf_length: Number of trailing bars after pivot point D to confirm a valid pattern (int, dft = 1) ββββincomplete: 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)
Notes de version
β
v69 Test allowing divergence checks with pivot length of 0
Notes de version
β
v70
Updated: pat_xabcd(x_is_low, pivot_length, source, conf_length, incomplete, inc_skipC) ββDetermine if an XABCD pattern has just completed (i.e. point D is on the previous bar) ββParameters: ββββx_is_low: Flag to determine if point X is a low pivot, i.e. bullish pattern (bool, dft = true) ββββpivot_length: Number of bars before and after a valid pivot (int, dft = 5) ββββsource: Source series (float, dft = na, will use high and low series) ββββconf_length: Number of trailing bars after pivot point D to confirm a valid pattern (int, dft = 1) ββββincomplete: Flag to return an incomplete XABC pattern (bool, dft = false) ββββinc_skipC: skip incomplete patterns whose point C is at or before this bar index (to avoid returning the same pattern on consecutive bars) ββ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)
Notes de version
β
v71
Notes de version
β
v72
Updated: pat_xabcd(x_is_low, pivot_length, source, conf_length, incomplete, inc_skipC) ββDetermine if an XABCD pattern has just completed (i.e. point D is on the previous bar) ββParameters: ββββx_is_low: Flag to determine if point X is a low pivot, i.e. bullish pattern (bool, dft = true) ββββpivot_length: Number of bars before and after a valid pivot (int, dft = 5) ββββsource: Source series (float, dft = na, will use high and low series) ββββconf_length: Number of trailing bars after pivot point D to confirm a valid pattern (int, dft = 1) ββββincomplete: Flag to return an incomplete XABC pattern (bool, dft = false) ββββinc_skipC: skip incomplete patterns whose point C is at this bar index (to avoid returning the same pattern on consecutive bars) ββ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)
Notes de version
β
v73
Notes de version
β
v74
Notes de version
β
v75
Updated: 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: Flag to determine if point X is a low pivot, i.e. bullish pattern (bool, dft = true) ββββpivot_length: Number of bars before and after a valid pivot (int, dft = 5) ββββsource: Source series (float, dft = na, will use high and low series) ββββconf_length: Number of trailing bars after pivot point D to confirm a valid pattern (int, dft = 1) ββββincomplete: 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)
Notes de version
β
v76
Updated: tradeClosed(eX, eY, stop, t1h, t2h, t1, t2) ββDetermine if Target or Stop was hit on the current bar ββParameters: ββββeX ββββeY ββββstop ββββt1h ββββt2h ββββt1 ββββt2
Notes de version
β
v77
Updated: 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: Flag to determine if point X is a low pivot, i.e. bullish pattern (bool, dft = true) ββββpivot_length: Number of bars before and after a valid pivot (int, dft = 5) ββββsource: Source series (float, dft = na, will use high and low series) ββββconf_length: Number of trailing bars after pivot point D to confirm a valid pattern (int, dft = 1) ββββincomplete: Flag to return an incomplete XABC pattern (bool, dft = false) ββReturns: [flag, x, a, b, c, d] flag = true if valid XABCD pattern completed on previous bar x = point X a = point A b = point B c = point C d = point D
Notes de version
β
v78 test revert d.y to 0.0
Notes de version
β
v79 Reverted changes using point object for pat_xabcd()
Updated: 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: Flag to determine if point X is a low pivot, i.e. bullish pattern (bool, dft = true) ββββpivot_length: Number of bars before and after a valid pivot (int, dft = 5) ββββsource: Source series (float, dft = na, will use high and low series) ββββconf_length: Number of trailing bars after pivot point D to confirm a valid pattern (int, dft = 1) ββββincomplete: 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)
Notes de version
β
v80 Add stop flag to tradeClosed()
Notes de version
β
v81
Added: test_cd(cd, bc, xa, xc, ad, pErr, p_types) ββValidate CD leg of XABCD ββParameters: ββββcd ββββbc ββββxa ββββxc ββββad ββββpErr ββββp_types
Notes de version
β
v82
Added: 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: Flag to determine if point X is a low pivot, i.e. bullish M pattern (bool, dft = true) ββββpivot_length: Number of bars before and after a valid pivot (int, dft = 5) ββββsource: Source series (float, dft = na, will use high and low series) ββββconf_length: 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)
This script is very nice, but there is one problem with calculating the "Shark Pattern". According to Harmonic Theory, "The Shark Pattern" doesn't require checking the validity of the retracement value of leg AB (or XA) against leg XA (or OX), but in practice there is a problem: In a particular shape called XABCD, if three retracement values are determined, mathematically the remaining one must be within a certain range! We need to define it in the script to capture the pattern correctly. It's probably between 0.382 and 0.618. Thank you for all your hard work.