PINE LIBRARY
Obj_XABCD_Harmonic

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 (float): Allowed % error of leg retracement ratio versus the defined harmonic ratio
pct_asym (float): 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<int>): Array of pattern types to validate (1=Gartley, 2=Bat, 3=Butterfly, 4=Crab, 5=Shark, 6=Cypher)
w_e (float): Weight of ratio % error (used in score calculation, dft = 1)
w_p (float): Weight of PRZ confluence (used in score calculation, dft = 1)
w_d (float): 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(x, a, b, c, d, params, tp, p)
Initialize an xabcd_harmonic object instance from a given set of points
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:
x (point type from dlmysolutions/Pattern/1): Point X
a (point type from dlmysolutions/Pattern/1): Point A
b (point type from dlmysolutions/Pattern/1): Point B
c (point type from dlmysolutions/Pattern/1): Point C
d (point type from dlmysolutions/Pattern/1): Point D
params (harmonic_params): harmonic_params used to validate and score the pattern. Validation will be skipped if a type (tp) is explicitly passed in.
tp (int): Pattern type
p (xabcd_harmonic): xabcd_harmonic object instance to initialize (optional, for re-validation/re-scoring)
Returns: xabcd_harmonic object instance if a valid harmonic, else na
init(xX, xY, aX, aY, bX, bY, cX, cY, dX, dY, params, tp, p)
Initialize an xabcd_harmonic object instance from a given set of x and y coordinate values.
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 (int): Point X bar index (required)
xY (float): Point X price/level (required)
aX (int): Point A bar index (required)
aY (float): Point A price/level (required)
bX (int): Point B bar index (required)
bY (float): Point B price/level (required)
cX (int): Point C bar index (required)
cY (float): Point C price/level (required)
dX (int): Point D bar index
dY (float): Point D price/level
params (harmonic_params): harmonic_params used to validate and score the pattern. Validation will be skipped if a type (tp) is explicitly passed in.
tp (int): Pattern type
p (xabcd_harmonic): xabcd_harmonic object instance to initialize (optional, for re-validation/re-scoring)
Returns: xabcd_harmonic object instance if a valid harmonic, else na
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 type from dlmysolutions/Pattern/1): Pattern
params (harmonic_params): harmonic_params used to validate and score the pattern. Validation will be skipped if a type (tp) is explicitly passed in.
tp (int): Pattern type
p (xabcd_harmonic): xabcd_harmonic object instance to initialize (optional, for re-validation/re-scoring)
Returns: xabcd_harmonic object instance if a valid harmonic, else na
method get_name(p)
Get the pattern name
Namespace types: xabcd_harmonic
Parameters:
p (xabcd_harmonic): Instance of xabcd_harmonic object
Returns: Pattern name (string)
method get_symbol(p)
Get the pattern symbol
Namespace types: xabcd_harmonic
Parameters:
p (xabcd_harmonic): Instance of xabcd_harmonic object
Returns: Pattern symbol (1 byte string)
method get_pid(p)
Get the Pattern ID. Patterns of the same type with the same coordinates will have the same Pattern ID.
Namespace types: xabcd_harmonic
Parameters:
p (xabcd_harmonic): Instance of xabcd_harmonic object
Returns: Pattern ID (string)
method 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.
Namespace types: xabcd_harmonic
Parameters:
p (xabcd_harmonic): Instance of xabcd_harmonic object
target (int): Target (1 or 2)
target_lvl (float): Target price/level (required if calc_target is not specified)
calc_target (string): 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)
method erase_pattern(p)
Erase the pattern
Namespace types: xabcd_harmonic
Parameters:
p (xabcd_harmonic): Instance of xabcd_harmonic object
Returns: p
method draw_pattern(p, clr)
Draw the pattern
Namespace types: xabcd_harmonic
Parameters:
p (xabcd_harmonic): Instance of xabcd_harmonic object
clr (color)
Returns: Pattern lines
[l1,l2,l3,l4,l5,l6]
method erase_label(p)
Erase the pattern label
Namespace types: xabcd_harmonic
Parameters:
p (xabcd_harmonic): Instance of xabcd_harmonic object
Returns: p
method draw_label(p, clr, txt_clr, txt, tooltip)
Draw the pattern label. Default text is the pattern name.
Namespace types: xabcd_harmonic
Parameters:
p (xabcd_harmonic): Instance of xabcd_harmonic object
clr (color): Label color
txt_clr (color): Text color
txt (string): Label text
tooltip (string): Tooltip text
Returns: Label
harmonic_params
Validation and scoring parameters for a Harmonic Pattern object (xabcd_harmonic)
Fields:
pct_error (series float): Allowed % error of leg retracement ratio versus the defined harmonic ratio
pct_asym (series float)
types (array<int>)
w_e (series float)
w_p (series float)
w_d (series float)
xabcd_harmonic
Harmonic Pattern object
Fields:
bull (series bool): Bullish pattern flag
tp (series int)
x (point type from dlmysolutions/Pattern/1)
a (point type from dlmysolutions/Pattern/1)
b (point type from dlmysolutions/Pattern/1)
c (point type from dlmysolutions/Pattern/1)
d (point type from dlmysolutions/Pattern/1)
r_xb (series float)
re_xb (series float)
r_ac (series float)
re_ac (series float)
r_bd (series float)
re_bd (series float)
r_xd (series float)
re_xd (series float)
score (series float)
score_eAvg (series float)
score_prz (series float)
score_eD (series float)
prz_bN (series float)
prz_bF (series float)
prz_xN (series float)
prz_xF (series float)
t1Hit (series bool): Target 1 flag
t1 (series float)
t2Hit (series bool)
t2 (series float)
sHit (series bool): Stop flag
stop (series float): Stop level
entry (series float): Entry level
eHit (series bool)
e (point type from dlmysolutions/Pattern/1)
invalid_d (series bool)
pLines (array<line>)
pLabel (series label)
pid (series string)
params (harmonic_params)
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 (float): Allowed % error of leg retracement ratio versus the defined harmonic ratio
pct_asym (float): 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<int>): Array of pattern types to validate (1=Gartley, 2=Bat, 3=Butterfly, 4=Crab, 5=Shark, 6=Cypher)
w_e (float): Weight of ratio % error (used in score calculation, dft = 1)
w_p (float): Weight of PRZ confluence (used in score calculation, dft = 1)
w_d (float): 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(x, a, b, c, d, params, tp, p)
Initialize an xabcd_harmonic object instance from a given set of points
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:
x (point type from dlmysolutions/Pattern/1): Point X
a (point type from dlmysolutions/Pattern/1): Point A
b (point type from dlmysolutions/Pattern/1): Point B
c (point type from dlmysolutions/Pattern/1): Point C
d (point type from dlmysolutions/Pattern/1): Point D
params (harmonic_params): harmonic_params used to validate and score the pattern. Validation will be skipped if a type (tp) is explicitly passed in.
tp (int): Pattern type
p (xabcd_harmonic): xabcd_harmonic object instance to initialize (optional, for re-validation/re-scoring)
Returns: xabcd_harmonic object instance if a valid harmonic, else na
init(xX, xY, aX, aY, bX, bY, cX, cY, dX, dY, params, tp, p)
Initialize an xabcd_harmonic object instance from a given set of x and y coordinate values.
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 (int): Point X bar index (required)
xY (float): Point X price/level (required)
aX (int): Point A bar index (required)
aY (float): Point A price/level (required)
bX (int): Point B bar index (required)
bY (float): Point B price/level (required)
cX (int): Point C bar index (required)
cY (float): Point C price/level (required)
dX (int): Point D bar index
dY (float): Point D price/level
params (harmonic_params): harmonic_params used to validate and score the pattern. Validation will be skipped if a type (tp) is explicitly passed in.
tp (int): Pattern type
p (xabcd_harmonic): xabcd_harmonic object instance to initialize (optional, for re-validation/re-scoring)
Returns: xabcd_harmonic object instance if a valid harmonic, else na
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 type from dlmysolutions/Pattern/1): Pattern
params (harmonic_params): harmonic_params used to validate and score the pattern. Validation will be skipped if a type (tp) is explicitly passed in.
tp (int): Pattern type
p (xabcd_harmonic): xabcd_harmonic object instance to initialize (optional, for re-validation/re-scoring)
Returns: xabcd_harmonic object instance if a valid harmonic, else na
method get_name(p)
Get the pattern name
Namespace types: xabcd_harmonic
Parameters:
p (xabcd_harmonic): Instance of xabcd_harmonic object
Returns: Pattern name (string)
method get_symbol(p)
Get the pattern symbol
Namespace types: xabcd_harmonic
Parameters:
p (xabcd_harmonic): Instance of xabcd_harmonic object
Returns: Pattern symbol (1 byte string)
method get_pid(p)
Get the Pattern ID. Patterns of the same type with the same coordinates will have the same Pattern ID.
Namespace types: xabcd_harmonic
Parameters:
p (xabcd_harmonic): Instance of xabcd_harmonic object
Returns: Pattern ID (string)
method 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.
Namespace types: xabcd_harmonic
Parameters:
p (xabcd_harmonic): Instance of xabcd_harmonic object
target (int): Target (1 or 2)
target_lvl (float): Target price/level (required if calc_target is not specified)
calc_target (string): 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)
method erase_pattern(p)
Erase the pattern
Namespace types: xabcd_harmonic
Parameters:
p (xabcd_harmonic): Instance of xabcd_harmonic object
Returns: p
method draw_pattern(p, clr)
Draw the pattern
Namespace types: xabcd_harmonic
Parameters:
p (xabcd_harmonic): Instance of xabcd_harmonic object
clr (color)
Returns: Pattern lines
[l1,l2,l3,l4,l5,l6]
method erase_label(p)
Erase the pattern label
Namespace types: xabcd_harmonic
Parameters:
p (xabcd_harmonic): Instance of xabcd_harmonic object
Returns: p
method draw_label(p, clr, txt_clr, txt, tooltip)
Draw the pattern label. Default text is the pattern name.
Namespace types: xabcd_harmonic
Parameters:
p (xabcd_harmonic): Instance of xabcd_harmonic object
clr (color): Label color
txt_clr (color): Text color
txt (string): Label text
tooltip (string): Tooltip text
Returns: Label
harmonic_params
Validation and scoring parameters for a Harmonic Pattern object (xabcd_harmonic)
Fields:
pct_error (series float): Allowed % error of leg retracement ratio versus the defined harmonic ratio
pct_asym (series float)
types (array<int>)
w_e (series float)
w_p (series float)
w_d (series float)
xabcd_harmonic
Harmonic Pattern object
Fields:
bull (series bool): Bullish pattern flag
tp (series int)
x (point type from dlmysolutions/Pattern/1)
a (point type from dlmysolutions/Pattern/1)
b (point type from dlmysolutions/Pattern/1)
c (point type from dlmysolutions/Pattern/1)
d (point type from dlmysolutions/Pattern/1)
r_xb (series float)
re_xb (series float)
r_ac (series float)
re_ac (series float)
r_bd (series float)
re_bd (series float)
r_xd (series float)
re_xd (series float)
score (series float)
score_eAvg (series float)
score_prz (series float)
score_eD (series float)
prz_bN (series float)
prz_bF (series float)
prz_xN (series float)
prz_xF (series float)
t1Hit (series bool): Target 1 flag
t1 (series float)
t2Hit (series bool)
t2 (series float)
sHit (series bool): Stop flag
stop (series float): Stop level
entry (series float): Entry level
eHit (series bool)
e (point type from dlmysolutions/Pattern/1)
invalid_d (series bool)
pLines (array<line>)
pLabel (series label)
pid (series string)
params (harmonic_params)
Biblioteca do Pine
No verdadeiro espirito do TradingView, o autor desse código Pine o publicou como uma biblioteca de código aberto, para que outros programadores Pine da nossa comunidade possam reusa-los. Parabéns ao autor! Você pode usar essa biblioteca privadamente ou em outras publicações de código aberto, mas a reutilização desse código em publicações é regida pelas Regras da Casa.
Aviso legal
As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.
Biblioteca do Pine
No verdadeiro espirito do TradingView, o autor desse código Pine o publicou como uma biblioteca de código aberto, para que outros programadores Pine da nossa comunidade possam reusa-los. Parabéns ao autor! Você pode usar essa biblioteca privadamente ou em outras publicações de código aberto, mas a reutilização desse código em publicações é regida pelas Regras da Casa.
Aviso legal
As informações e publicações não devem ser e não constituem conselhos ou recomendações financeiras, de investimento, de negociação ou de qualquer outro tipo, fornecidas ou endossadas pela TradingView. Leia mais em Termos de uso.