Library "Obj_XABCD_Harmonic" Harmonic XABCD Pattern object and associated methods. Easily validate, draw, and get information about harmonic patterns. See example code at the end of the script for details.
init_params(pct_error, pct_asym, types, w_e, w_p, w_d) Create a harmonic parameters object (used by xabcd_harmonic object for pattern validation and scoring). Parameters: pct_error: Allowed % error of leg retracement ratio versus the defined harmonic ratio pct_asym: Allowed leg length/period asymmetry % (a leg is considered invalid if it is this % longer or shorter than the average length of the other legs) types: Array of pattern types to validate (1=Gartley, 2=Bat, 3=Butterfly, 4=Crab, 5=Shark, 6=Cypher) w_e: Weight of ratio % error (used in score calculation, dft = 1) w_p: Weight of PRZ confluence (used in score calculation, dft = 1) w_d: Weight of Point D / PRZ confluence (used in score calculation, dft = 1) Returns: harmonic_params object instance. It is recommended to store and reuse this object for multiple xabcd_harmonic objects rather than creating new params objects unnecessarily.
init(xX, xY, aX, aY, bX, bY, cX, cY, dX, dY, params, tp, p) Initialize an xabcd_harmonic object instance. If the pattern is valid, an xabcd_harmonic object instance is returned. If you want to specify your own validation and scoring parameters, you can do so by passing a harmonic_params object (params). Or, if you prefer to do your own validation, you can explicitly pass the harmonic pattern type (tp) and validation will be skipped. You can also pass in an existing xabcd_harmonic instance if you wish to re-initialize it (e.g. for re-validation and/or re-scoring). Parameters: xX: Point X bar index xY: Point X price/level aX: Point A bar index aY: Point A price/level bX: Point B bar index bY: Point B price/level cX: Point C bar index cY: Point C price/level dX: Point D bar index dY: Point D price/level params: harmonic_params used to validate and score the pattern. Validation will be skipped if a type (tp) is explicitly passed in. tp: Pattern type p: xabcd_harmonic object instance to initialize (optional, for re-validation/re-scoring) Returns: xabcd_harmonic object instance if a valid harmonic, else na
get_name(p) Get the pattern name Parameters: p: Instance of xabcd_harmonic object Returns: Pattern name (string)
get_symbol(p) Get the pattern symbol Parameters: p: Instance of xabcd_harmonic object Returns: Pattern symbol (1 byte string)
get_pid(p) Get the Pattern ID. Patterns of the same type with the same coordinates will have the same Pattern ID. Parameters: p: Instance of xabcd_harmonic object Returns: Pattern ID (string)
set_target(p, target, target_lvl, calc_target) Set value for a target. Use the calc_target parameter to automatically calculate the target for a specific harmonic ratio. Parameters: p: Instance of xabcd_harmonic object target: Target (1 or 2) target_lvl: Target price/level (required if calc_target is not specified) calc_target: Target to auto calculate (required if target is not specified) Options: [".382 AD", ".5 AD", ".618 AD", "1.272 AD", "1.618 AD" ".382 XA", ".5 XA" ,".618 XA", "1.272 XA", "1.618 XA", ".382 CD", ".5 CD", ".618 CD", "1.272 CD", "1.618 CD", "A", "B", "C"] Returns: Target price/level (float)
erase_pattern(p) Erase the pattern Parameters: p: Instance of xabcd_harmonic object Returns: p
draw_pattern(p) Draw the pattern Parameters: p: Instance of xabcd_harmonic object Returns: Pattern lines [l1,l2,l3,l4,l5,l6]
erase_label(p) Erase the pattern label Parameters: p: Instance of xabcd_harmonic object Returns: p
draw_label(p, txt, tooltip, clr, txt_clr) Draw the pattern label. Default text is the pattern name. Parameters: p: Instance of xabcd_harmonic object txt: Label text tooltip: Tooltip text clr: Label color txt_clr: Text color Returns: Label
harmonic_params Validation and scoring parameters for a Harmonic Pattern object (xabcd_harmonic) Fields: pct_error: Allowed % error of leg retracement ratio versus the defined harmonic ratio pct_asym types w_e w_p w_d
xabcd_harmonic Harmonic Pattern object Fields: bull: Bullish pattern flag tp xX xY aX aY bX bY cX cY dX dY r_xb re_xb r_ac re_ac r_bd re_bd r_xd re_xd score score_eAvg score_prz score_eD prz_bN prz_bF prz_xN prz_xF t1Hit: Target 1 flag t1 t2Hit t2 sHit: Stop flag stop: Stop level entry: Entry level eHit eX eY pLines pLabel pid params
릴리즈 노트
⋅
v2 Fixed validation of incomplete patterns (i.e. when calling init() with no Point D coordinates)
릴리즈 노트
⋅
v3 Delete existing drawings on init()
릴리즈 노트
⋅
v4
Updated: xabcd_harmonic Harmonic Pattern object Fields: bull: Bullish pattern flag tp xX xY aX aY bX bY cX cY dX dY r_xb re_xb r_ac re_ac r_bd re_bd r_xd re_xd score score_eAvg score_prz score_eD prz_bN prz_bF prz_xN prz_xF t1Hit: Target 1 flag t1 t2Hit t2 sHit: Stop flag stop: Stop level entry: Entry level eHit eX eY invalid_d pLines pLabel pid params
릴리즈 노트
⋅
v5
릴리즈 노트
⋅
v6
Updated to use point, leg, and pattern objects.
Updated: init(pattern, params, tp, p) Initialize an xabcd_harmonic object instance from a given pattern If the pattern is valid, an xabcd_harmonic object instance is returned. If you want to specify your own validation and scoring parameters, you can do so by passing a harmonic_params object (params). Or, if you prefer to do your own validation, you can explicitly pass the harmonic pattern type (tp) and validation will be skipped. You can also pass in an existing xabcd_harmonic instance if you wish to re-initialize it (e.g. for re-validation and/or re-scoring). Parameters: pattern: Pattern params: harmonic_params used to validate and score the pattern. Validation will be skipped if a type (tp) is explicitly passed in. tp: Pattern type p: xabcd_harmonic object instance to initialize (optional, for re-validation/re-scoring) Returns: xabcd_harmonic object instance if a valid harmonic, else na
xabcd_harmonic Harmonic Pattern object Fields: bull: Bullish pattern flag tp x a b c d r_xb re_xb r_ac re_ac r_bd re_bd r_xd re_xd score score_eAvg score_prz score_eD prz_bN prz_bF prz_xN prz_xF t1Hit: Target 1 flag t1 t2Hit t2 sHit: Stop flag stop: Stop level entry: Entry level eHit e invalid_d pLines pLabel pid params
릴리즈 노트
⋅
v7 Fixed bug when calling init with point D = na
릴리즈 노트
⋅
v8 Initialize point e on init()
릴리즈 노트
⋅
v9 Don't overwrite entry point when initializing an existing pattern
@HPotter, thanks! These UDTs are a real game-changer for Pine
iQ_Trader1
⋅
iQ_Trader1
⋅
@iQ_Trader1, To be honest, I still don't understand how to use it, how is it different from the Custom XABCD Validation and Backtesting Tool?.
But I am very grateful and proud of your work on the Harmonic and ABCD Script Patterns.
Amazing 👍👍👍
reees
⋅
@iQ_Trader1, thanks! This is a Pine Script Library used by the Harmonic Pattern Detection, Prediction, and Backtesting tool. Basically a set of data structure and function definitions, interesting only to Pine programmers
Indyan
⋅
Looking forward to see this library in action in your harmonic pattern detection, prediction, and backtesting tool.Thanks