PINE LIBRARY
FibonacciRetracement

Hi all!
This library will help you draw Fibonacci retracement levels (zones). The code is from my indicator "Fibonacci retracement" (tradingview.com/script/yFIioDwi-Fibonacci-retracement/). You can see that description for more information about the behaviour and example of how to use this library. The code is almost the same with the addition of alerts. If the alert frequency is 'alert.freq_once_per_bar_close' alert messages will be concatenated and have a header saying how many messages it contains (if it's more than 1).
Hope this is of help!
Library "FibonacciRetracement"
ConcateAlerts(context)
Concatenates all alerts from the bar to one string (separated by new lines) and clears alert messages on the current bar.
Parameters:
context (Context)
AddAlert(context, message, unshiftInsteadOfPush)
Parameters:
context (Context)
message (string)
unshiftInsteadOfPush (bool)
Range(context, structure, settings)
Will return values if new levels/zones should be drawn.
Parameters:
context (Context): The 'Context' for the Fibonacci retracement.
structure (Structure type from mickes/PriceAction/1): The current 'Structure' from the 'MarketStructure' library.
settings (Settings): The 'Settings' object for the 'Context'.
Returns: A tuple with the start and end pivot if new zones should be drawn, '[na, na]' otherwise.
DrawAll(context, settings, start, end)
Draws lines and labels for the zone. It will also set the 'Price' value that will be used for absolute positions.
Parameters:
context (Context): The 'Context' for the Fibonacci retracement.
settings (Settings): The 'Settings' object for the 'Context'.
start (Pivot type from mickes/PriceAction/1)
end (Pivot type from mickes/PriceAction/1)
AlertActive(context, settings)
Will alert for all zones that are active. If multiple alert messages are added they will be concatenated (separated by a new line) with a header saying how many messages the alert contains.
Parameters:
context (Context): The 'Context' for the Fibonacci retracement. This contains the zones that will be alerted if price (wick or close according to the settings) enters it.
settings (Settings): The 'Settings' object for the 'Context'.
TrendlineSettings
Holds all the values for 'TrendlineSettings'.
Fields:
Enabled (series bool): If the trendline should be visible or not.
Color (series color): The color of the trendline.
Style (series string): The style of the trendline (as a string).
GenericZonesSettings
Holds all the values for 'GenericZonesSettings', that will be applicable to all drawn objects.
Fields:
ExtendRight (series bool): If all lines should extend to the right or not.
Style (series string): The style of all drawn lines
Reverse (series bool): If true, all lines will be reversed.
Prices (series bool): If price levels should be shown or not.
Levels (series bool): If levels should be shown or not.
LevelsValue (series string): Either 'Value' or 'Percent'. Defined if value or percentage should be shown.
FontSize (series int): The for size of the text in labels drawn.
LabelsPosition (series string): Coul be 'Left', 'Rigth' or 'Adapt'. 'Adapt' will try to adapt the labels position to the prices.
ZoneSettings
Holds all the values for 'ZoneSettings'.
Fields:
Enabled (series bool): If this zone is enabled or not.
Level (series float): The level of the zone.
Color (series color): The color that will be displayed.
Price (series float): The price of the level. Will be set internally.
Settings
Holds all the values for 'Settings'.
Fields:
PivotLeftLength (series int): The left length used to find pivots through the 'MarketStructure' library.
PivotRightLength (series int): The right length used to find pivots through the 'MarketStructure' library.
Trendline (TrendlineSettings): The settings for the 'Trendline' object.
GenericZonesSettings (GenericZonesSettings): The setting applicable to all zones.
AlertFrequency (series string): The frequency for the alerts. If 'alert.freq_once_per_bar_close', alert messages will be concatenated and have a header saying how many messages it contains (if it's more than 1).
AlertPrice (series string): The price that has to enter a zone. Can be 'Close' (the closing price) or 'Wick' (the whole candle needs to be in the zone).
Zone1 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone2 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone3 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone4 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone5 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone6 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone7 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone8 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone9 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone10 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone11 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone12 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone13 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone14 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone15 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone16 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone17 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone18 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone19 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone20 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone21 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone22 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone23 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone24 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Context
Holds all the values for 'Context'.
Fields:
Lines (array<line>): All the drawn lines for the current 'Context'.
Labels (array<label>): All the drawn labels for the current 'Context'.
Boxes (array<box>): All the drawn boxes for the current 'Context'.
Alerts (array<string>): All the alert messages on the current tick.
Start (series int): The start bar index of the current 'Context'.
This library will help you draw Fibonacci retracement levels (zones). The code is from my indicator "Fibonacci retracement" (tradingview.com/script/yFIioDwi-Fibonacci-retracement/). You can see that description for more information about the behaviour and example of how to use this library. The code is almost the same with the addition of alerts. If the alert frequency is 'alert.freq_once_per_bar_close' alert messages will be concatenated and have a header saying how many messages it contains (if it's more than 1).
Hope this is of help!
Library "FibonacciRetracement"
ConcateAlerts(context)
Concatenates all alerts from the bar to one string (separated by new lines) and clears alert messages on the current bar.
Parameters:
context (Context)
AddAlert(context, message, unshiftInsteadOfPush)
Parameters:
context (Context)
message (string)
unshiftInsteadOfPush (bool)
Range(context, structure, settings)
Will return values if new levels/zones should be drawn.
Parameters:
context (Context): The 'Context' for the Fibonacci retracement.
structure (Structure type from mickes/PriceAction/1): The current 'Structure' from the 'MarketStructure' library.
settings (Settings): The 'Settings' object for the 'Context'.
Returns: A tuple with the start and end pivot if new zones should be drawn, '[na, na]' otherwise.
DrawAll(context, settings, start, end)
Draws lines and labels for the zone. It will also set the 'Price' value that will be used for absolute positions.
Parameters:
context (Context): The 'Context' for the Fibonacci retracement.
settings (Settings): The 'Settings' object for the 'Context'.
start (Pivot type from mickes/PriceAction/1)
end (Pivot type from mickes/PriceAction/1)
AlertActive(context, settings)
Will alert for all zones that are active. If multiple alert messages are added they will be concatenated (separated by a new line) with a header saying how many messages the alert contains.
Parameters:
context (Context): The 'Context' for the Fibonacci retracement. This contains the zones that will be alerted if price (wick or close according to the settings) enters it.
settings (Settings): The 'Settings' object for the 'Context'.
TrendlineSettings
Holds all the values for 'TrendlineSettings'.
Fields:
Enabled (series bool): If the trendline should be visible or not.
Color (series color): The color of the trendline.
Style (series string): The style of the trendline (as a string).
GenericZonesSettings
Holds all the values for 'GenericZonesSettings', that will be applicable to all drawn objects.
Fields:
ExtendRight (series bool): If all lines should extend to the right or not.
Style (series string): The style of all drawn lines
Reverse (series bool): If true, all lines will be reversed.
Prices (series bool): If price levels should be shown or not.
Levels (series bool): If levels should be shown or not.
LevelsValue (series string): Either 'Value' or 'Percent'. Defined if value or percentage should be shown.
FontSize (series int): The for size of the text in labels drawn.
LabelsPosition (series string): Coul be 'Left', 'Rigth' or 'Adapt'. 'Adapt' will try to adapt the labels position to the prices.
ZoneSettings
Holds all the values for 'ZoneSettings'.
Fields:
Enabled (series bool): If this zone is enabled or not.
Level (series float): The level of the zone.
Color (series color): The color that will be displayed.
Price (series float): The price of the level. Will be set internally.
Settings
Holds all the values for 'Settings'.
Fields:
PivotLeftLength (series int): The left length used to find pivots through the 'MarketStructure' library.
PivotRightLength (series int): The right length used to find pivots through the 'MarketStructure' library.
Trendline (TrendlineSettings): The settings for the 'Trendline' object.
GenericZonesSettings (GenericZonesSettings): The setting applicable to all zones.
AlertFrequency (series string): The frequency for the alerts. If 'alert.freq_once_per_bar_close', alert messages will be concatenated and have a header saying how many messages it contains (if it's more than 1).
AlertPrice (series string): The price that has to enter a zone. Can be 'Close' (the closing price) or 'Wick' (the whole candle needs to be in the zone).
Zone1 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone2 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone3 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone4 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone5 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone6 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone7 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone8 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone9 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone10 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone11 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone12 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone13 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone14 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone15 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone16 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone17 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone18 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone19 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone20 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone21 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone22 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone23 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Zone24 (ZoneSettings): The 'ZoneSettings' that represents this zone.
Context
Holds all the values for 'Context'.
Fields:
Lines (array<line>): All the drawn lines for the current 'Context'.
Labels (array<label>): All the drawn labels for the current 'Context'.
Boxes (array<box>): All the drawn boxes for the current 'Context'.
Alerts (array<string>): All the alert messages on the current tick.
Start (series int): The start bar index of the current 'Context'.
Thư viện Pine
Theo tinh thần TradingView thực sự, tác giả đã xuất bản mã Pine này dưới dạng thư viện nguồn mở để các lập trình viên Pine khác trong cộng đồng của chúng tôi có thể sử dụng lại. Xin tri ân tác giả! Bạn có thể sử dụng thư viện này riêng tư hoặc trong các bài đăng nguồn mở khác. Tuy nhiên, bạn cần sử dụng lại mã này theo Nội quy chung.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.
Thư viện Pine
Theo tinh thần TradingView thực sự, tác giả đã xuất bản mã Pine này dưới dạng thư viện nguồn mở để các lập trình viên Pine khác trong cộng đồng của chúng tôi có thể sử dụng lại. Xin tri ân tác giả! Bạn có thể sử dụng thư viện này riêng tư hoặc trong các bài đăng nguồn mở khác. Tuy nhiên, bạn cần sử dụng lại mã này theo Nội quy chung.
Thông báo miễn trừ trách nhiệm
Thông tin và ấn phẩm không có nghĩa là và không cấu thành, tài chính, đầu tư, kinh doanh, hoặc các loại lời khuyên hoặc khuyến nghị khác được cung cấp hoặc xác nhận bởi TradingView. Đọc thêm trong Điều khoản sử dụng.