PINE LIBRARY
Pattern

Library  "Pattern"
Pattern object definitions and functions. Easily draw and keep track of patterns, legs, and points.
Supported pattern types:
Type Leg validation # legs
"xabcd" Direction 3 or 4 (point D not required)
"zigzag" Direction >= 2
"free" None >= 2
Summary of exported types and associated methods/functions:
type point A point on the chart (x,y)
draw_label() Draw a point label
erase_label() Erase a point label
type leg A pattern leg (i.e. point A to point B)
leg_init() Initialize/instantiate a leg
draw() Draw a leg
erase() Erase a leg
leg_getLineTerms() Get the slope and y-intercept of a leg
leg_getPrice() Get price (Y) at a given bar index (X) within a leg
type pattern A pattern (set of at least 2 connected legs)
pattern_init() Initialize/instantiate a pattern
draw() Draw a pattern
erase() Erase a pattern
*See bottom of the script for example usage*
erase_label(this)
Delete the point label
Parameters:
this (point): Point
Returns: Void
draw_label(this, position, clr, transp, txt_clr, txt, tooltip, size)
Draw the point label
Parameters:
this (point): Point
position (string)
clr (color)
transp (float)
txt_clr (color)
txt (string)
tooltip (string)
size (string)
Returns: line
leg_init(a, b, prev, next, line)
Initialize a pattern leg
Parameters:
a (point): Point A (required)
b (point): Point B (required)
prev (leg): Previous leg
next (leg): Next leg
line (line): Line
Returns: New instance of leg object
erase(this)
Delete the pattern leg
Parameters:
this (leg): Leg
Returns: Void
erase(this)
Delete the pattern lines
Parameters:
this (pattern): Pattern
Returns: Void
draw(this, clr, style, transp, width)
Draw the pattern leg
Parameters:
this (leg): Leg
clr (color): Color
style (string): Style ("solid", "dotted", "dashed", "arrowleft", "arrowright")
transp (float): Transparency
width (int): Width
Returns: line
draw(this, clr, style, transp, width)
Draw the pattern
Parameters:
this (pattern): Pattern
clr (color): Color
style (string): Style ("solid", "dotted", "dashed", "arrowleft", "arrowright")
transp (float): Transparency
width (int): Width
Returns: line[]
leg_getLineTerms(this)
Get the slope and y-intercept of a leg
Parameters:
this (leg): Leg
Returns: [slope, y-intercept]
leg_getPrice(this, index)
Get the price (Y) at a given bar index (X) within the leg
Parameters:
this (leg): Leg
index (int): Bar index
Returns: Price (float)
pattern_init(legs, tp, name, subType, pid)
Initialize a pattern object from a given set of legs
Parameters:
legs (array<leg>): Array of pattern legs (required)
tp (string): Pattern type ("zigzag", "xabcd", or "free". dft = "free")
name (string): Pattern name
subType (string): Pattern subtype
pid (string): Pattern Identifier string
Returns: New instance of pattern object, if one was successfully created
pattern_init(points, tp, name, subType, pid)
Initialize a pattern object from a given set of points
Parameters:
points (array<point>)
tp (string): Pattern type ("zigzag", "xabcd", or "free". dft = "free")
name (string): Pattern name
subType (string): Pattern subtype
pid (string): Pattern Identifier string
Returns: New instance of pattern object, if one was successfully created
point
A point on the chart (x,y)
Fields:
x (series int): Bar index (x coordinate)
y (series float)
label (series label)
leg
A pattern leg (point A to point B)
Fields:
a (point): Point A
b (point)
deltaX (series int)
deltaY (series float)
prev (leg)
next (leg)
retrace (series float)
line (series line)
pattern
A pattern (set of at least 2 connected legs)
Fields:
legs (array<leg>)
type (series string)
subType (series string)
name (series string)
pid (series string)
Pattern object definitions and functions. Easily draw and keep track of patterns, legs, and points.
Supported pattern types:
Type Leg validation # legs
"xabcd" Direction 3 or 4 (point D not required)
"zigzag" Direction >= 2
"free" None >= 2
Summary of exported types and associated methods/functions:
type point A point on the chart (x,y)
draw_label() Draw a point label
erase_label() Erase a point label
type leg A pattern leg (i.e. point A to point B)
leg_init() Initialize/instantiate a leg
draw() Draw a leg
erase() Erase a leg
leg_getLineTerms() Get the slope and y-intercept of a leg
leg_getPrice() Get price (Y) at a given bar index (X) within a leg
type pattern A pattern (set of at least 2 connected legs)
pattern_init() Initialize/instantiate a pattern
draw() Draw a pattern
erase() Erase a pattern
*See bottom of the script for example usage*
erase_label(this)
Delete the point label
Parameters:
this (point): Point
Returns: Void
draw_label(this, position, clr, transp, txt_clr, txt, tooltip, size)
Draw the point label
Parameters:
this (point): Point
position (string)
clr (color)
transp (float)
txt_clr (color)
txt (string)
tooltip (string)
size (string)
Returns: line
leg_init(a, b, prev, next, line)
Initialize a pattern leg
Parameters:
a (point): Point A (required)
b (point): Point B (required)
prev (leg): Previous leg
next (leg): Next leg
line (line): Line
Returns: New instance of leg object
erase(this)
Delete the pattern leg
Parameters:
this (leg): Leg
Returns: Void
erase(this)
Delete the pattern lines
Parameters:
this (pattern): Pattern
Returns: Void
draw(this, clr, style, transp, width)
Draw the pattern leg
Parameters:
this (leg): Leg
clr (color): Color
style (string): Style ("solid", "dotted", "dashed", "arrowleft", "arrowright")
transp (float): Transparency
width (int): Width
Returns: line
draw(this, clr, style, transp, width)
Draw the pattern
Parameters:
this (pattern): Pattern
clr (color): Color
style (string): Style ("solid", "dotted", "dashed", "arrowleft", "arrowright")
transp (float): Transparency
width (int): Width
Returns: line[]
leg_getLineTerms(this)
Get the slope and y-intercept of a leg
Parameters:
this (leg): Leg
Returns: [slope, y-intercept]
leg_getPrice(this, index)
Get the price (Y) at a given bar index (X) within the leg
Parameters:
this (leg): Leg
index (int): Bar index
Returns: Price (float)
pattern_init(legs, tp, name, subType, pid)
Initialize a pattern object from a given set of legs
Parameters:
legs (array<leg>): Array of pattern legs (required)
tp (string): Pattern type ("zigzag", "xabcd", or "free". dft = "free")
name (string): Pattern name
subType (string): Pattern subtype
pid (string): Pattern Identifier string
Returns: New instance of pattern object, if one was successfully created
pattern_init(points, tp, name, subType, pid)
Initialize a pattern object from a given set of points
Parameters:
points (array<point>)
tp (string): Pattern type ("zigzag", "xabcd", or "free". dft = "free")
name (string): Pattern name
subType (string): Pattern subtype
pid (string): Pattern Identifier string
Returns: New instance of pattern object, if one was successfully created
point
A point on the chart (x,y)
Fields:
x (series int): Bar index (x coordinate)
y (series float)
label (series label)
leg
A pattern leg (point A to point B)
Fields:
a (point): Point A
b (point)
deltaX (series int)
deltaY (series float)
prev (leg)
next (leg)
retrace (series float)
line (series line)
pattern
A pattern (set of at least 2 connected legs)
Fields:
legs (array<leg>)
type (series string)
subType (series string)
name (series string)
pid (series string)
Pineライブラリ
TradingViewの精神に則り、作者はPineコードをオープンソースライブラリとして公開し、コミュニティ内の他のPineプログラマーが再利用できるようにしました。作者に敬意を表します!このライブラリを個人的に、または他のオープンソースの投稿で使用することができますが、このコードを投稿で再利用するには、ハウスルールに準拠する必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または保証する金融、投資、取引、またはその他の種類のアドバイスや推奨を意図したものではなく、またそのようなものでもありません。詳しくは利用規約をご覧ください。
Pineライブラリ
TradingViewの精神に則り、作者はPineコードをオープンソースライブラリとして公開し、コミュニティ内の他のPineプログラマーが再利用できるようにしました。作者に敬意を表します!このライブラリを個人的に、または他のオープンソースの投稿で使用することができますが、このコードを投稿で再利用するには、ハウスルールに準拠する必要があります。
免責事項
これらの情報および投稿は、TradingViewが提供または保証する金融、投資、取引、またはその他の種類のアドバイスや推奨を意図したものではなく、またそのようなものでもありません。詳しくは利用規約をご覧ください。