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'.
Pine脚本库
本着真正的TradingView精神,作者将此Pine代码发布为开源库,以便我们社区的其他Pine程序员可以重复使用它。向作者致敬!您可以私密或在其他开源出版物中使用此库,但在出版物中重复使用此代码受网站规则约束。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。
Pine脚本库
本着真正的TradingView精神,作者将此Pine代码发布为开源库,以便我们社区的其他Pine程序员可以重复使用它。向作者致敬!您可以私密或在其他开源出版物中使用此库,但在出版物中重复使用此代码受网站规则约束。
免责声明
这些信息和出版物并不意味着也不构成TradingView提供或认可的金融、投资、交易或其它类型的建议或背书。请在使用条款阅读更多信息。