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提供或認可的金融、投資、交易或其他類型的意見或建議。請在使用條款閱讀更多資訊。