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: 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
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
リリースノート
v2Fixed validation of incomplete patterns (i.e. when calling init() with no Point D coordinates)
リリースノート
v3Delete existing drawings on init()
リリースノート
v4Updated:
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リリースノート
v6Updated 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
リリースノート
v7Fixed bug when calling init with point D = na
リリースノート
v8Initialize point e on init()
リリースノート
v9Don't overwrite entry point when initializing an existing pattern
リリースノート
v10Pineライブラリ
TradingViewの精神に則り、作者はPineコードをオープンソースライブラリとして公開し、コミュニティ内の他のPineプログラマーが再利用できるようにしました。作者に敬意を表します!このライブラリを個人的に、または他のオープンソースの投稿で使用することができますが、このコードを投稿で再利用するには、ハウスルールに準拠する必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または保証する金融、投資、取引、またはその他の種類のアドバイスや推奨を意図したものではなく、またそのようなものでもありません。詳しくは利用規約をご覧ください。
Pineライブラリ
TradingViewの精神に則り、作者はPineコードをオープンソースライブラリとして公開し、コミュニティ内の他のPineプログラマーが再利用できるようにしました。作者に敬意を表します!このライブラリを個人的に、または他のオープンソースの投稿で使用することができますが、このコードを投稿で再利用するには、ハウスルールに準拠する必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または保証する金融、投資、取引、またはその他の種類のアドバイスや推奨を意図したものではなく、またそのようなものでもありません。詳しくは利用規約をご覧ください。